What Is Docker Container

What Is Docker Container

Docker is a product developed by the company of the same name. Originally developed by a French engineer, Solomon Hykes, the product was unveiled in March 2013. Since then, Docker has become THE fashionable app! We will see what it serves and how you can use it on a daily basis.

What is Docker?

what is docker

​Docker makes it possible to create environments (called containers) so as to isolate applications. Until then, I have remained very pragmatic… Docker relies on Linux kernel and on a feature: the containers, which you may already know under the sweet name of LXC. The idea is to run code (or run a task, if you prefer) in an isolated environment. I will stop here for the details of the Linux containers, instead focusing on the features highlighted by Docker. Finally, a third component is required, cgroups which will aim to manage resources (use of RAM, CPU among others).​Docker makes it possible to create environments (called containers) so as to isolate applications.

Docker, isolate an environment? Like a VM?

​Yes and no! Docker and Linux containers do not behave in the same way as a VM. A virtual machine isolates an entire system (its OS) and has its own resources.​In the case of  Docker, the kernel will share the resources of the host system and interact with the container (s). Technically, Docker is not a VM, not the least in the world, but in terms of use, Docker may be related to a VM.

​Launching an environment, and isolating the components of this container with the components of my host, this is what Docker knows how to do! It does it very well and remains an alternative much better than the VMs (for equivalent use).

container vs vm

Schema realized by Docker themselves.
  • ​Ok, I understand better. In a virtual machine, you allocate “physically” RAM and storage, such as 2GB of RAM and 20GB. While on Docker, everything is shared with the Linux host that uses Docker. That’s why everything is faster, I’m wrong?

​It’s exactly that! If you already have a little experience with virtual machines ( Virtual Box or even with Vagrant ), you will see that Docker is much, much faster! Besides, if Docker looks like a VM from afar, here’s a point that should convince you that it is not one. Docker can be installed on a Linux only and can instantiate from Linux only. Convinced?

Docker, only on Linux?

docker on linux

​Lets discussed the compatibility between Windows and Docker. I already see the heads of some who are not convinced. Maybe you’ve already tried it or used it through Windows or MacOS. However, Docker can work only with the presence of Kernel Linux!​​In spite of not excluding developers working on a platform other than Linux, VMs (yes this time we talk about real virtual machines) have been put in place. The best known is boot2docker. It relies on a VM VirtualBox. This virtual machine contains a Linux which will then be able to execute a Docker. Obviously, an instance is enough to run as many Dockers as you want. Since the filing GitHub of boot2docker, it is indicated that it weighs about 24 MB and starts in about 5 seconds.

​​In this way, all developers, whatever their platform, are able to work on the same application, with a similar environment.

​​Ok, if I summarize: Docker only installs on Linux, so to run it on Mac or Windows, you need a VM that hosts it. Is not it a little bit the snake that has died its tail?

​Yes, however, boot2docker and other available VMs are not intended to work in production, but only for developers wishing to place themselves under the exact conditions as the production servers.

​As part of a production, the use of a Linux environment (and therefore not a Docker) is HIGHLY advised.

​​Attention, Docker requires a version 3.8 of the Kernel  (compatible therefore for a Debian 8 or Ubuntu) at least. For the servers that are currently on Debian 7 (so with a kernel in version 3.2), the team in charge of development Docker has implemented a fallback to install a newer kernel without having to upgrade to Debian  8 called Jessie).

​​Docker, soon available natively on Windows.

​Now, Docker is only available for Linux but a recent partnership between Docker Inc. and Microsoft provides for Windows container development. These will not be compatible with Linux but will meet the same need.

Docker, use case

​Let us take a case of simple and concrete use.​A Lyon company that I will call at random

Wanadev, wishes to develop a Symfony project as they know how to do. Their team is made up of two people.

  • Manu is an old man of old. He, Debian 7, is perfect. In addition, it is ISO with production servers.
  • Baptiste is a true hippie. It features the latest exotic distribution. He, PHP, is the latest version or nothing. However, it can generate code that cannot run correctly with an older version, such as that of Manu.

​Until today, we all said, “let’s do unit tests”. Yes, this answered a good part of our problems (on the condition of doing good unit tests).

​​In fact, it is a problem that two developers do not work on the same environments … So, thanks to Docker, we can make sure that Manu and Baptiste work on the same Linux versions without fear of problems compatibility between their codes respective?

Exactly! In this case, the simplest is to set up a Dockerfile,  “conductor” document, which will allow Manu and Baptiste to mount a similar image. By being smart, this Dockerfile will be modeled on the elements present in production. Therefore, Manu and Baptiste, in addition to working on an identical environment, will be in an environment similar to that of production!

Docker, deploy your applications easily

docker deploy applications easily

​In my previous example, I highlighted the use of Docker to declare a single development environment. I think all Docker users should start with this before seeing bigger.

Above, I was talking about a particular version of PHP. It is obvious that you will not forget to install PHP on your production server, but maybe the configuration of your PHPFPM will be slightly different. Perhaps you need an additional library like Imagick and its PHP extension. Maybe you need a Postfix to send emails. As many details as you might forget when you mount your production server.​To limit these errors, would it not be simpler to deploy the container (s) to run your application? In this way, rather than pulling source code and performing some deployment scripts, you could deploy a packaged consistent packet matching an application.

​​We often talk about an application in the world of the web, a ” Symfony ” application, would not be much without a front end like Nginx or Apache2,  an engine like FPM or HHVM, and a database.

If I can run multiple Dockers on my machine, does that mean I can multiply the configurations as I wish?

That’s quite right! In this way, you can build self-contained and isolated environments. The good old project SPIP in 5.3 could rub shoulders on the same server the last project Symfony with PHP 5.5. Cool not?

Conclusion

​With Docker, multiply the environments on your machine without limiting the performance of your computer. Resources are shared with the host machine! Each environment can be configured simply by its Dockerfile, present at its root.​This article was intended to introduce you to Docker in general terms and to enable you to better understand the solutions that can be brought to the various problems of the developers. The rest of this article will be published in a few days. It will give you a first example of creating a Docker environment thanks to its Dockerfile.

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. AcceptRead More