Docker - tool that performs containerization on operating-system level. It uses the resource isolation features of the Linux kernel to allow independent containers to run within a single Linux instance, avoiding the overhead of starting and management virtual machines. It is developed by Docker, Inc.
dockerd - docker daemon, persistent process that manages Docker containers and handles container objects. Daemon listens for requests sent via the Docker Engine API. The command docker
allows user to interact with Docker daemons with command line interface (CLI).
Container - isolated environment that runs application. A container is managed from Docker API or CLI.
Image - read-only template used to build containers. Images used to build and distribute applications.
Registry - repository for Docker images. Docker client can pull & push images from & to registry. Registry can be public(no need to sign in to pull/push images) or private(auth is required). The default registry for each docker client is Docker Hub, but docker client can be configured to use any other docker registry (AWS ECR, Azure CR, Gitlab CR and others).
Tool that helps define, manage and run multi-container Docker applications. It uses YAML files to setup the applications and perform a start-up process with a single command. docker-compose CLI utility allows users to run commands on multiple containers at the same time (e.g. building, scale, run, stop etc). The docker-compose.yml file is used to define an application's services.
Clustering functionality for Docker. Unites a few Docker engines into a single virtual one. Swarm CLI utility allows users to manage cluster nodes and containers.
List of instructions which Docker Client will run to build an image.
Consider this Dockerfile
as reference:
FROM ubuntu:18.10
COPY . /app
CMD python /app/app.py
Each instruction starts from the new line with some command. (e.g. FROM
, COPY
, CMD
)
In this example:
FROM
- define which Docker image use as a skeleton, in this case it'subuntu:18.10
COPY
- copy everything in.
to/app
CMD
- define command to run application in Docker container Please read the most common commands for theDockerfile
(FROM
,LABEL
,RUN
,WORKDIR
,COPY
,EXPOSE
,ENV
,CMD
)
If you want to build custom Docker container with your defined Dockerfile
run:
docker build .
You can also specify container name and tag by running:
docker build -t <container_name>:<tag> .
Docker Client will send the build context to the Docker daemon and run each command from your Dockerfile
.
If you want to list all running docker containers in your computer just run:
docker ps
You can also list all(include stopped) containers with --all
flag:
docker ps --all
To run already builded docker container enter:
docker run <container_name>:<tag>
You can also map your local ports with docker container exposed ports by adding -p
flag:
docker run -p <local_port>:<docker_port> <container_name>:<tag>
Also it's a good to know, that you allowed to use -i
and -t
flags which give you possibility to keep STDIN open and also adds pseudo-tty.
docker run -it -p <local_port>:<docker_port> <container_name>:<tag>
For the regular stop:
docker stop <container_name>
For the immediate stop:
docker kill <container_name>
For all images:
docker rmi $(docker images -q)
For all containers:
docker rm $(docker ps -aq)
Due to -i
and -t
flags you have opportunity to run custom commands inside the running docker container (e.g. bash
)
docker exec -it <container_name> bash