Containers are similar to VMs, except that while VMs create new kernels, containers typically share kernels and operating level resources with the host system. This results in faster boot times in exchange for lower levels of isolation.
- Concepts in container technologies
- Introduction of the Dockerfile
- Understand and use basic Docker commands
- Build, configure and deploy a container
- Optimising image specification files
There are three main entities in container technologies - the image specification, the image, and the container.
The image specification is a blueprint of what the image will contain. Developers run docker build
to create the image.
The image is a result of the build process. Think of images as logical classes which can then be instantiated by docker run
into a container.
Containers are basically instances of images, implying that multiple containers can be generated from an image.
The Dockerfile is a directive based image specification file that tells Docker how an image should be built. Thus, the Dockerfile will contain some, all, or more of the following basic directives:
Directive | Description |
---|---|
FROM |
Indicates which operating system we should be using |
ARG |
Specifies build-time only arguments |
ENV |
Specifies environment variables that persist after build-time |
RUN |
Indicates commands to be run when docker build is executed |
COPY |
Copies files from your local machine into the image |
ENTRYPOINT |
Specifies the command to be run when the image is instantiated into a container. |
WORKDIR |
Specifies the working directory - where the container should start from |
Here are some basic CLI commands to get started. We will cover their practical use cases in the activites of this section. All of the following commands should be prefixed with docker
when executing in your terminal.
Command | Description |
---|---|
build |
Builds a Dockerfile |
container ls |
Lists all running containers |
container ls -a |
Lists all containers |
network ls |
Lists all networks |
image ls |
Lists all images |
volume ls |
Lists all volumes |
top <CONTAINER_ID> |
Shows statistics on all running containers |
run |
Instantiates an image into a container |
exec -it |
Executes into a specified container |
Click here to move onto Provisioning an Environment.