DEVOPS: What Is Docker and Why Is It Important?

July 11th, 2016

DevOps / Case Studies // Grossum Possum

What is Docker and how it can enhance the productivity of your developers

What’s up with the whale?

The instruments to work with projects from the development point of view abound. One of them has gained quite a lot of popularity lately - Docker, an open-source and actively developing tool in the last few years.

Its logo - a blue whale with a stack of shipping containers on its back - describes the general gist of the tool: creating and working with virtual containers. It’s a virtualization system on the system core level based on Linux. (Unfortunately, so far it does not support MacOS or Windows, except when a boot2docker “crutch” is used.)

WHY DO YOU NEED DOCKER?

A virtual machine, in general, allows setting up several projects that require various software versions on the same computer. Without such a virtual machine, you can either setup just one project or a couple requiring the same libraries.

Besides the raised work efficiency, such setup allows minimizing the expenses spent on server rental or cloud storage because it optimizes the resources’ usage. It also protects from the viruses - so in case you get a code from your client that contains a virus, your main machine would not be harmed.

WHAT ARE THE ADVANTAGES OF DOCKER?

Docker uses much less RAM than popular Vagrant because it utilizes only the resources it needs right at the moment.

  • Using Docker solves several efficiency problems. For example, compared to the other popular tool called Vagrant, Docker uses much less RAM because it utilizes only the resources it needs right at the moment (instead of allotting parts of RAM to various projects.
  • A new container can be set up within 5 milliseconds. (Yeah, that fast!)
  • In case the need arises, you can transfer your project easily to a new server.
  • Scalability is also an important point - using Docker containers, you can create 20 projects out of one within a few minutes.
  • You can link the containers from different projects among themselves.
  • Mounting volumes: You can connect the server’s file system to the project to synchronize it between the developer and the project. This is done to increase the speed and security as well as to make the project’s files more conveniently accessible to the developers.
  • Security system agility. You don’t have to specify a backup for each container separately, but instead, create a backup for all folders / volumes on one server.

TIPS & TRICKS OF WORKING WITH DOCKER

Installing and Setting Up

  • Prior to creating containers, you should create volumes for technologies.
  • There is a Docker image and Docker container. When you create the image, you manually configure the system environment structure, where you specify where to download the components’ files (the versions that you need for the project).
  • Finally, when you create the container, you specify the Docker image and volume you’ve already created in previous steps.
  • When creating containers, you should stick to the rule of “One service per one container” (for example, MySQL, PHP, Nginx in separate containers that are linked later).
  • While this is not a required step, it allows you to easily set up systems afterward because you can choose from, for example, PHP 5.6 and PHP 7, without having to do with what you’ve already got in your container, making your task much more flexible.
  • It also makes your project more stable because you can easily fix a problem with one container (that has just one service).

Components’ Collaboration in High-load Systems

  • You can link the containers so that they would be able to “see” each other and you won’t have to do additional work in setting up the network permissions. (Access rights are assigned to the container names.)
  • The auto-scaling feature helps you to create as many containers as you need, using orchestration systems to make sure your project would work correctly. This would provide automatic load balancing.

Network Security

  • By default, all ports are closed in Docker. Even if someone decides to scan your ports, they won’t see anything you don’t want to show. On one hand, this is an advantage when it comes to security. On the other hand, you have to constantly open the ports for work and it takes the time to manually do it. The way to fix this is to reassemble the container, but it's better to specify which ports should be open when you are creating the Docker image.
  • Dynamic IP address of the container also adds an additional security level to your project. The IP is changed when you restart the container in case of zombie processes (which happen rarely). Don’t worry - you won’t need any additional corrections within the project when the IP changes - all your services will work correctly.

What Should One Remember Working With Docker?

  • Docker does not have any autostart system available. This is advantageous when it comes to launching speed, but it’s also a drawback because you have to manually launch containers.
  • Do not use the latest available version of technology on your project. It’s better to manually specify which versions you need - that way you would avoid raw software and libraries’ versions (as well as problems associated with core version.)
  • Use Load Balancer for proper load distribution when creating a container.
  • It is better not to reassemble containers if you need any changes done. Instead, create a new container with necessary parameters to save time and resources (and save the old container for future work in case you’d need a setup.)

Need DevOps for your project?

Author: Grossum Possum

Grossum Possum. He loves using Symfony2 for his projects and learning to implement Symfony3. He also likes developing web and mobile applications using other programming languages and frameworks, such as PHP and Java. In his free time, Grossum Possum likes to write about his experiences in the blog.

Tags Services

See all blog

x

Grossum Startup Guide:
Five Things to Consider Before Web & Mobile Development

Get the Guide