5 reasons I like Docker

Docker has recently been one of the hottest words in the web technology world. But why is it so? Isn’t it just another “hyper tool” that will be forgotten in a year?

I’ve been using Docker for one year to develop and deploy both professional and pet projects. During this year Docker has been improved a lot and has became a very cozy tool to easily deal with a development and a deployment of web applications. I find it be a lot better than my previous stack, which was a tandem of Vagrant and Puppet.

I’m giving you top 5 reasons why I like Docker to encourage you to give it a try!

1. Portability

An intermodal container revolutionized the cargo transport. Containers can be used across different modes of transport — from ship to rail to track — without unloading and reloading their cargo.

An intermodal container revolutionized the cargo transport the same way as Docker revolutionizes web applications deployment

The same idea stands behind Docker. You create a virtual container with an application and its dependencies once and you can run it on any Linux server — on your laptop, your local server, public or private cloud etc. It means that, if you want, your local development environment can be exactly the same as the production environment. Of course, you can easily share the environment configuration with your teammates, so that all of your team members can have exactly the same development environment and setting up the environment for a new guy in the team is fast and easy.

2. Isolation

Docker uses resource isolation features of the Linux kernel such as cgroups and kernel namespaces, so that every container run within a single Linux instance is independent and isolated from other containers as well as the host. It means that you can maintain different development or production environments on one machine without a hustle. For example, you can run different PHP versions, different databases or web servers without a risk that one tool will spoil the other tool or the host machine.

3. Performance

You may say that both isolation and portability can be achieved with Vagrant and provisioning tools like Puppet or Ansible. Yes, they can. But one of the most important drawbacks of Vagrant, or generally virtual machines, is that they are heavy and often slow. Docker containers don’t include a separate operating system, like virtual machines do. Instead, they all share the same Linux kernel and in consequence the performance of Docker containers is nearly identical to bare metal (source)!

The difference between standard VM and Docker

An important fact is that you can run Docker Engine only on Linux, so if you develop on Mac OS or Windows you still need a virtual machine to run Docker. Docker created the additional tool called Docker Machine that creates a transparent virtual machine with Docker Engine on non-Linux operating systems. Even thought the work performance of Docker on Mac or Windows won’t be a lot better than Vagrant, still spinning up and down Docker containers is much faster than starting and stopping virtual machines.

What’s more, Docker images have layered structure, are cached and can be easily shared, what makes provisioning much faster than with Ansible or Puppet.

4. Modularity

The idea of Docker is to run only one process on a container. It means that each part of your stack, like a web server or a database, should be run in a separate container. In fact, you can create your Docker environment using different linked together containers, the same way you build something with Lego bricks! Thanks to Docker Compose it is super easy to manage containers in your environment. All you need to do is to find a proper image on Docker Hub or create one by yourself and put its configuration into the docker-compose.yml file.

Wanted to find out if Varnish will speed up your app? Just add it to your stack and link it to your web container. Wanted to switch from MySQL to PostgreSQL? Simply change the base image in your db container definition. On Docker Hub you will find a number of preconfigured images for popular web tools.

5. Community

The popularity of Docker is growing at an enormous pace. At the moment, Docker is 18th most stared repo on GitHub and it is only 700 stars behind Torvald’s Linux repo! On Docker Hub, the ultimate source of Docker images, there are 86 official images for different tools and thousands of unofficial images created by the community. If you want to test out some framework or tool, it’s highly probable that there has been already some preconfigured image with it and it can be easily tried out.

What’s more, there are more than 50 thousand of repos on GitHub connected to Docker with eg. sample Docker Compose configurations or additional tools to Docker Machine. If you use Mac OS and want to speed up your Docker Machine, you may want to use Docker Machine NFS app. And if by any chance you are Symfony developer, you may want to check out my repo with sample Docker Compose configuration to run Symfony2 project.

I hope that, if you had any doubts whether to use Docker or not, these points convinced you to give it a try. If so, you may want to start your adventure with Docker by following the official Docker user guide. And if you are interested in a real life use case, you may check out my blog posts about developing and deploying Wordpress app with Docker.

UPDATE: This post is now available as a short video presentation!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.