Mohammad D.

What is Docker and why do developers use it?

Mohammad Dohadwala3 min read

Ian Taylor

Photo by Ian Taylor on Unsplash

If you have been using computers for a long time, then you might have heard of something called Virtual Machines. Right? Well, Docker solves the same problems as virtual machines but in a much different way. Let me explain, but let's start by answering: What is Docker?

What is Docker?

Docker is a tool that allows you to package an application and its dependencies in a very light container. It is as you took a complete application with absolutely everything it needs to function, so you can transport it to any other server with Docker installed. Either to continue developing it or to deploy it.

"But wait, that's all Docker does? Carry code? I am pretty sure ZIP files can do that too.". Well yes, but not exactly. Let me try to explain it to you in a really simple way.

The need for Docker

To explain what Docker is used for, we are going to create a hypothetical and multidisciplinary team of three.

  • Ahmed: He uses Windows because he likes the ease.
  • Farha: She prefers using MacOS because it is more elegant and intuitive.
  • Marium: She loves Linux because she is a nerd.

They all are working on a certain project together using their computers. One of them installs a package that works fine on their system but that package has a dependency that behaves differently on the rest of the team's computers.

Ahmed, Farha, and Marium conclude that to fix this problem, they would have to all use the same operating system; Ubuntu. Since that is the distribution where the final project will be hosted.

  • Ahmed uses a live USB to run the newest version of Ubuntu on his PC.
  • Farha installs Ubuntu from a CD copy that she kept in her desk drawer.
  • And Marium, well she keeps her operating system as it was.

Even though they all installed the same distribution of Linux, the project still runs differently on each of their systems. You see, all 3 of them are using different versions of Ubuntu. And, each of them has its custom configuration setup on their computers. It turns out, it's not as easy as they thought it would be. Someone, please tell them about Docker.

Docker allows us to run our applications inside containers, each with its role, operating system, and resources. Containers are very light compared to Virtual Machines which take up a lot of space and take much longer to boot up.

Ahmed and Farha can go back to using their favorite operating system and install Docker. Once they strap their project with it, it will run the same way on each of their machines. Problem solved.

Docker and Virtual Machines

Docker vs Virtual Machines

On the left, we can see that, in the case of containers, the applications interact directly with Docker, and this, in turn, with the operating system.

And on the right we have several applications, each application running on its own operating system, that's right, three complete operating systems monopolizing resources, doesn't that sound pretty inefficient? Under these virtual machines, the software in charge of creating and running them (Hypervisor) interacts with the operating system.

In addition to the differences in structure, Docker performs optimizations at the time of execution, such as using a single operating system if multiple containers use it.

Summary

For practical purposes, Docker allows us to create applications that can be transported from one environment to another easily, and it will behave exactly one way on any machine. It will get rid of the famous: "It works on my machine".

Today, 9 out of 10 of the world's biggest tech companies use Docker somewhere in their software development pipeline. All major cloud providers offer managed ways to host your containers in the cloud. As of writing this article, over 7 million applications run on Docker.

Docker is great, but you don't have to use it in every project. Adding one more layer of complexity to a project is something that must be evaluated for each use case. In the end, Docker is one more tool that should be used to solve a problem that exists or is likely to exist.

Liked it? Share it!