0% found this document useful (0 votes)
6 views8 pages

07 Docker Basics

Docker is an open platform for developing, shipping, and running applications in lightweight containers, which are isolated environments that share the host's kernel. Docker images serve as read-only templates for creating containers, and changes are managed through a layered file system. The document also discusses Dockerfiles for building images, running containers, and utilizing Docker Hub for accessing public images.

Uploaded by

aabanprasla1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views8 pages

07 Docker Basics

Docker is an open platform for developing, shipping, and running applications in lightweight containers, which are isolated environments that share the host's kernel. Docker images serve as read-only templates for creating containers, and changes are managed through a layered file system. The document also discusses Dockerfiles for building images, running containers, and utilizing Docker Hub for accessing public images.

Uploaded by

aabanprasla1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Software Test Automation Ch 7 Page 1 (8)

Docker basics 15.4.2021 KRL

Docker basics
• Docker is an open platform for developing, shipping, and running
applications
• Docker provides the ability to package and run an application in a loosely
isolated environment called a container
• Container are similar to virtual machines in the sense that they don’t rely on
what is installed on the host
• Containers are lightweight
• Containers are not virtual machines! – they just package everything that is
needed to run an application in to same ”package”
• All containers run on the same kernel – typically same kernel as the host
machine runs
• Linux containers on Windows and OSX run a linux kernel aside with the
main OS
Software Test Automation Ch 7 Page 2 (8)
Docker basics 15.4.2021 KRL

Docker architecture

Docker registry = repository

Image source: https://docs.docker.com/get-started/overview/


Software Test Automation Ch 7 Page 3 (8)
Docker basics 15.4.2021 KRL

Concepts
• An image is a read-only template with instructions for creating a Docker
container. Often, an image is based on another image, with some
additional customization.
• A container is a runnable instance of an image. You can create, start,
stop, move, or delete a container using the Docker API or CLI. You can
connect a container to one or more networks, attach storage to it, or even
create a new image based on its current state.
• By default, a container is relatively well isolated from other containers and
its host machine. You can control how isolated a container’s network,
storage, or other underlying subsystems are from other containers or from
the host machine.
• A container is defined by its image as well as any configuration options you
provide to it when you create or start it. When a container is removed,
any changes to its state that are not stored in persistent storage
disappear.
Software Test Automation Ch 7 Page 4 (8)
Docker basics 15.4.2021 KRL

Image layers
• A docker image uses layered file system
• When you make changes to files or add files they don’t replace or
overwrite existing files, the changes go to a new layer that is applied on
”top” of the previous layer
When we access a file we start from the top of the layer
• Example: stack and traverse down until we find the file. That way
we always get the most recent version of the file.

You add hello.c to /app directory

Image source: https://blogs.cisco.com/developer/container-image-layers-1


Software Test Automation Ch 7 Page 5 (8)
Docker basics 15.4.2021 KRL

Dockerfiles
• A recipe to build an image is called dockerfile
• Example:
Base image
FROM ubuntu:xenial
RUN apt-get update && apt-get upgrade –y
RUN apt-get install gcc build-essential git gzip gawk gcc-multilib -y

• Each line in the dockerfile creates a new layer


• There is a relatively small set of commands to build the image
• Copy files to image from local computer or previous build stage
• Set user and working directory
• Map network ports, etc.
• Layers in the image are cached and they are immutable (= read only)
• Docker assumes that same command always produces the same
output – sometimes you have disable caching
Software Test Automation Ch 7 Page 6 (8)
Docker basics 15.4.2021 KRL

Running a container
• When you run a container you need to specify
which image you want to run
• Docker then adds a read-write layer on top
of the image and makes it a runnable
container
• The original image is not modified. All

Layers from image


changes go to the read-write layer
• You can stop a container and re-start is later. All
changes in the read-write layer are preserved.
• This is not meant as persistent storage. You
can use it for continuing interrupted work or
if you want to test different settings before
making changes to the docker file
• Persistent data should be stored on volumes or
bind-mounted directories
• If you build environment runs in a container
you can bind mount sources to the container
Software Test Automation Ch 7 Page 7 (8)
Docker basics 15.4.2021 KRL

Docker hub
• When you install Docker the default registry is Docker hub
• Contains many publicly available images that you can use as starting
point
• Ubuntu is often an easy way to get started but the image is often quite
bloated – Alpine linux based image seems to be a popular minimal
image
• You can create an account which allows you to push images to hub
• For our purposes we can just pull what we need from Docker hub and
do the rest locally
Software Test Automation Ch 7 Page 8 (8)
Docker basics 15.4.2021 KRL

What are we going to use Docker for?


• We will run Jenkins in a container
• No need to install it locally
• Persistent data goes into a volume
• Easy to remove if no longer needed
• Easier to manage than virtual machines
• We can start and stop services from the command line

You might also like