Learn docker in 5 minutes

Your quickstart guide to docker…

Subham Kundu
TheLeanProgrammer
4 min readMay 14, 2021

--

After finishing my blog on CI and CD (click here), today I am going to explain another hot topic of the software industry i.e docker. Today out of 10 software professionals 9 will say they use docker. So what is docker, why it has become the de-facto of today’s software industry?

There are many blogs and articles on the internet which explain to us why we need docker. So, I will just do a crisp explanation for why we need docker and I will take more time explaining different components of docker and how they work.

Few years ago physical systems were the only thing on which everyone was dependent but it raised many problems such as:

  1. Manual Installation on every server and every environment. (Environment in the sense of UAT, CI, and Production which I explained in my previous blog).
  2. Resolving issues related to dependencies and library. For example, in your local env, you have the Tensorflow 1.x version but in production, you have TensorFlow 2.x. Hence it will arise issues for this.

The above two reasons were the primary reasons for which developers started thinking something different.

So you must be thinking that docker came into the limelight after this. Your assumption was wrong.

In the virtual machine, we have a hypervisor above which we install our operating system. So everyone thought the problem is solved but with virtual machines, new problems came such as availability of ports, manual IP configuration on each virtual machine, and hence again a lot of monotonous work.

Now you are right, docker came to the limelight to solve these problems. Before going deeper please examine the following images to understand physical machines and virtual machines.

Traditional System and Virtual System (Visual representation)

I am going to clear one misconception — People think that docker is applicable only to the virtual machine. This is completely wrong.

Docker does not depend on whether you use it directly on physical machines or virtual machines. Docker means only one thing i.e. containerizing your applications. You can think of docker as a cargo ship containing thousands of containers and each container can contain any item let it be a car or any other item.

So if we go with this example, we can say our resources (can be both physical and virtual machines) are the ship and docker gives us the containers in which we ship our items i.e. our applications.

Now, why should we use docker? The answer is we should use docker for containerizing our applications. Now, why should we containerize our applications:

  1. Containers are flexible. The most complex applications can be containerized.
  2. Containers leverage and share the host kernel which makes it efficient in utilization in terms of system resources and this is why it is more preferred than virtual machines.
  3. Containers can easily be built on localhost and can be run on the cloud or anywhere and this makes containers very favorable for the developers as the world is moving towards 100% cloud computing.
  4. Containers play an important role in Kubernetes (I will write a separate blog on Kubernetes)

I think the above is enough to understand why docker is such an emerging technology in the market now. Now let’s move to docker architecture.

Docker Architecture
  1. Docker Daemon: The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes.
  2. Docker Client: Docker client can be present on either Docker Host or any other machine. The Docker client (docker) is the primary way that many Docker users interact with Docker. When you use commands such as docker run, the client sends these commands to dockerd (Docker Daemon), which carries them out.
  3. Docker Images: Docker images are one of the most important to understand and you can this is the nervous system of docker. It is a read-only template for giving instructions to run a container. So an image itself never runs at any cost. A docker image is normally based on another simple image. For example, we want to run a web server, so what we do we tell our customized docker image to install ubuntu and then install Nginx on it and then expose the port etc. In my next blog, I will write specifically about the internal working of each and every docker command and how they work.
  4. Docker Containers: It is a runnable instance of an image. We can create, start, stop, move, or delete a container. We can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state. We can communicate with the docker containers using Docker Api or CLI.

So I think after reading up to this you are familiar with how docker works and why it is needed. Docker will emerge as a de-facto technology in the coming years.

In my next blog, I will dig deeper into docker commands and show you hands-on how to create a docker image from scratch, upload it in the docker hub and pull it.

For any doubt or questions, you can shoot an email to me at subhamkundu999@gmail.com.

And whoever is reading it’s a request from my side please wear a double mask, stay safe and healthy.

Don’t forget to follow The Lean Programmer Publication for more such articles, and subscribe to our newsletter tinyletter.com/TheLeanProgrammer

--

--