Docker: Why, How & What?

Docker: Why, How & What?

Hello folks, in this article I am going to put down my understanding of Docker. I don't consider this to be a tutorial since many have already explained this beautifully and I don't want to make it redundant.


Why?

As Simon Sinek has greatly said Start with Why, let me follow this great guy and start with Why's of the Docker.

In my understanding, Docker helps the developer to package his app efficiently for running it in various environments.

But again package is a very vague term so let me clear that.

When I say package efficiently it means:

  • Put it in, you can say, a box.
  • A box, if you can imagine, which will hold the information required for running the app along with the app itself.
  • Information such as OS, dependencies & libraries, executable code and the command to run that code. An example could be a Node.js app. The OS required would be, say, Ubuntu, the dependencies will be node & npm/yarn, libraries would be express, the executable code would contain app.js, package.json & yarn.json OR package.lock.json and the command to run will be node app.js.
  • Now, you may put this box on any computing machine (laptop, desktop, servers, edge devices, etc), which has the ability to manage & run that box.
  • Also you can create clones of this box and/or update its contents like code or libraries.

So, in layman's terms, Docker will help you put everything related to your app in box and make it available to run anywhere.

Secondly, Docker can help you scale your app easily

As I said earlier, Docker will package it and you can then create clones of it. You can use Docker Swarm, Kubernetes, Nomad, etc orchestration tools for scaling aid. More about this in upcoming articles.

Finally, it can help you form a virtual network to run the apps securely and make them highly available

This means you can form a network between your boxes, expose only whatever is required and make sure that in case if anything goes down, it is up again within few minutes.

How?

So how does Docker exactly do this?

Well, to me, you have to write a file that will act as a blueprint of high-level commands that are required to create the template for the box. The template will dictate how the box shall behave.

The process is pretty simple. You have to write the blueprint, and then build an image, then push this image to some cloud registries, pull the image on the machine where you want to run the container and run it by along with manifest settings such as env variables, port mapping, volume mapping, and other behaviors.

Alt Text

The application runs on the host's kernel but has its OS. This is achieved via OS-level virtualization and isolation of resources.

Services running on host OS are not shared with containers until explicitly configured. For example, the GCC installed in your current OS, and the GCC inside the container are not the same.

Even services within two different containers are not the same. Alt Text

What?

According to Wikipedia

Docker is a set of the platform as a service products that uses OS-level virtualization to deliver software in packages called containers.

With Docker, you can achieve all the above things. This out of box solution will help you in dependency management, virtualization, scaling, and orchestrating of software developed to run in distributed systems architecture.

Bibliography

Official Docker Website
Docker Docs
Docker Hub
Docker Tutorial by freeCodeCamp