Containerization is often referred to as one particular technology – Docker. In this article, we’ll detail how Docker works, how to get started with it, and what alternatives it has.There will also be a practical part where we will create our docker image and launch the container.
We will not tell you what containers are and what they are used for. If you are not already familiar with this topic, read our article on containerization. And in this article, we will focus specifically on Docker.
Docker is a platform for developing and running containers. Docker allows you to create containers, automates their launch, and manages the lifecycle. Docker consists of several components:
This is the computer that Docker is running on. It can be a regular personal computer, an iron server, or a virtual machine in the cloud.
It is a background process that runs continuously and waits for a command. All operations for managing containers are sent to the daemon, for example: start or stop a container, download an image. And based on these commands, the daemon performs the necessary actions with containers and images. Therefore, the docker daemon knows everything about the containers running on one host: how many containers are there, which ones are running, where the images are stored, and so on.
This is a client through which users interact with the daemon and send commands to it. It can be a console, API, or GUI.
Docker Image (Docker Image)
This is the immutable image from which the container unfolds. It can be thought of as a collection of files required to get an application up and running on another host. An analogy from the world of installing software can be used: an image is a CD from which a program is installed.
This is an already deployed and running application; the analogy with installing software, a container, can be compared to an already installed and running program on a PC.
This is the repository where the images are stored. When developers build applications, they host their images in these repositories, from where other people can download them. There are public repositories like Docker Hub. And you can create your repository for use within a company or team.
This is an instruction file for building an image.
Let’s look at a few example commands and see how Docker reacts to them and what happens. Please note that all orders from the client go to the daemon, which performs the desired action.
- Docker pull: This command downloads an image from the docker registry and puts it into local storage on the host.
- Docker build: This command reads a docker file and makes an image.
- Docker run: This command creates a container from an image and runs it.
Also Read: How Docker Images And Containers Work