Docker Containers

by Andriy Kravets,
Magento Team Lead

October 30, 2017

In our previous post our expert shared his insights on Docker and its valuable features that can be utilised for software development success. In this part we will go into more technical intricacies on Docker containers and why they are important for flawless software development processes.

Why do containers matter?

Container is an abstraction at the application layer that packages code and dependencies together. Containers isolate software from its surroundings, e.g., isolate differences between development and staging environments and help reduce conflicts between development teams running different software on the same infrastructure.
Multiple containers can run on the same computer and share the OS kernel with other containers, each running as isolated process in user space.

Docker container conditions

Docker containers running on a single machine share that very machine’s operating system kernel; they start instantly and use less memory. With Docker every process can be built into the binary view and be ready for the release at any moment.
This container’s condition is called image. The image can be sent to the server and executed immediately. Images are constructed from file system layers and share common files. This minimizes disk usage and increases image downloads.

A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Its structure comprises a cascade of layers. Image-layer is the particular set of commands that should be executed to install the “image-layer” mode, with the read-only option for other levels. So, every image possesses exclusively the changes directly applied to it, and utilises only the existing layers.

We can easily cache and reuse these layers. The level of the container’s alterations is represented by the particular file called Dockerfile. It allows for the fulfillment of a variety of actions during build and release of the container. These can be Linux OS bash queries, environment variables setup, executing scripts, etc. This is “dockerizing” the process of the container building.

How do containers work?

Each container can have its own permission/restriction to access the file system or the network. To start “dockerizing” applications, you should create a Dockerfolder with the dependencies you want to apply. It can be an image of Ubuntu/Debian if you need. Then you need to specify instructions with the specific markup. Every container should have an entry point which runs your application. The container automatically stops upon the completion of the process.

The Docker golden rule is one container solves one issue; no matter how many processes are involved in it, Docker can run with multiple processes in a container.

Containers management

There is a specific process that manages containers, it is called Docker Daemon. It handles the containers’ build, pull and run operations.

container management process Forbytes

The process works using the unix socket /var/run/docker.sock by default or the 2375 port.
Docker Daemon is responsible for checking running containers and resolving possible conflicts in that respect. You, as a user will have to import environment variables including port settings, mapping, etc., in order to be able to send commands to Docker Daemon.
This is also important in the communication between the user and the final running processes. At the same time, it is recommended to run only one instance of Docker Daemon because it allows for the container to be easily re-used for other projects or purposes.

Conclusion

The best thing about Docker is the flexibility it unlocks for IT organizations. The decision on how and where to run your applications comes from what is right for your business. With Docker containers, you get the perfect combination of agility, portability, and performance; if this makes sense for your software development company, then Docker is the right solution for you.

For further advice on such areas of expertise as Magento development, e-Commerce development and more feel free to contact us to find out how can we help your business.