How Docker Images And Containers Work

How Docker Images And Containers Work

A docker image is made up of layers. Each command in the docker file adds a new layer that overlays the previous one. The final Docker image is the merging of all layers into one.

This structure allows you to use existing images to create new ones. For example, we are developing applications in Python. For our applications to run on other servers, we must install the Python runtime in each image. In order not to implement this ourselves, we use the ready-made official Python image. In turn, this image is based on the Debian image, a Linux distribution. Python cannot work without it.

This approach also allows you to download the Python image once and use it for our applications. This way, we save disk space and do not duplicate the same files.

An image is read-only immutable layers. And the container is the same image, which has one more layer “on top” for recording. The container uses it when it needs to save information in its work: logs, temporary files, and so on. If the container is destroyed, then this layer and all information on it will also be lost. And when a new container is created from the same image, the recording layer will be new and empty.

Creating And Running Docker Containers

Let’s move on to practice. First, download the finished image and launch the container from it. Then we will create our application, wrap it in an image and run it in Docker.

First, you need to install Docker. We will not describe this step because it differs depending on the OS and Linux distribution. Installation instructions are on the official website.

Launching The Container

First, we will download the already built image and launch the container. Run the command in the console:

Docker Analogs

Docker has become the de facto standard in the container world. Often when people talk about containers, they mean Docker containers. But this is not the only implementation of the containerization technology; there are others:


Has a command-line interface that is very similar to Docker commands. The main difference from Docker is that Podman does not have a separate daemon; it is a standalone utility. Podman is used as the default container management tool in Fedora Linux distributions.


An OS-level virtualization system, not a standalone platform like Docker. It creates a separate virtual environment with its own process space and network stack, in which all containers use a single instance of the OS kernel. LXC is often seen as a cross between a chroot and an entire virtual machine.


An engine that was initially focused on modern cloud applications. In 2019, development stopped, and the engine was archived. Perhaps you can still find projects where it is used. But in new developments, rkt is no longer worth choosing.

Docker Is Cloud-Friendly

Docker containers can be run not only on their servers but also in the cloud. Firstly, it will allow you not to deal with the servers’ selection, purchase, and configuration. Secondly, cloud providers have developed many ready-made services that provide additional benefits.

Also Read: The Best Alternatives To Google Photos


Leave a Reply

Your email address will not be published. Required fields are marked *