All about Docker - Beginner's Insight

Before diving into what Docker is and the details of it, let us first try to understand why to use Docker and what problem does it solve.


Suppose, you are installing a software on your machine. So the steps we follow are downloading a software and installing it. During installation, we often get errors due to some other setup and dependencies. We then try to troubleshoot it and continue our installation. Like this, we might get many errors and keep on troubleshooting the issues. This is where Docker can help. 

Docker makes it easy to install a software without getting into any kind of setup or dependency issue.
Using Docker we can install any software using just one command and then start using that software. At the end of this article, there is a basic video tutorial of how to install docker and how to install and run an application using Docker.

So, what is Docker?

Going by definition:

Docker is a platform, that uses OS-level virtualization to enable developers to install and run any application as a lightweight, portable package known as container.

Now, to understand this definition in depth we first need to know about different components in the Docker Ecosystem and then about Containers.

Docker Ecosystem is basically a collection of different projects and tools that helps in installing and running any application via Docker.


So, here we can say six different tools in the docker ecosystem. Let's get a brief idea on each of them.

  • Docker Client: When we install docker on our system, we generally use the CLI to interact with other docker tools from our system. So, the CLI in our system becomes a Docker Client.
  • Docker Server: A docker server is the one that handles all the requests from the client like when a client requests to install an application, it requests the docker server, the docker server then fetches the image of that application from the docker hub.
  • Docker Hub: It is a place where the images of each application is stored. It is like an online repository of applications from where docker fetches and installs any application on our system.
  • Docker Image: In some of the points above, we mentioned about images of an application. What are we referring to as image is basically a docker image. A Docker Image of an application is a single file with all the dependencies and configuration required to run that application.
  • Docker Compose: In the next section we will see what are containers. Docker Compose is a tool that allows us to run multiple containers and provides a way to interact between them.
  • Docker Machine:Docker Machine is a tool that allows us to run Docker in a variety of environments, like on a virtual environment or on a cloud system

 What is a Container?

In the previous section learned what a Docker Image is. So the image of an application is a single file containing all configurations and dependencies needed to run that application. Now when we install any application using Docker, the image of the application gets downloaded. To run this image we need hardware resources like memory, network drivers and hard disk space. Now, we don't run these images directly on our system, instead these images are run using Containers. A container is a sort of virtual environment which is totally independent and has its own set of hardware resources.  Inside a container, we have an instance of the image of an application and the application runs inside the container using its hardware resources. We can create as many containers on our system and use them to run the same image, but each of these containers will run in complete isolation, i.e an application running in one container won't affect the application in another container.

 

Let's dig a bit deep and see how containers work.
To have a better understanding of how containers work, one should have a brief idea of an OS kernel. The OS kernel is a software process that governs access between all the application programs running on a system and all the physical hardware like CPU, Memory, etc. Any application process like Chrome or NodeJS cannot access the hardware directly, instead they make system calls to the kernel and kernel assigns the hardware resources to them.
Now, when we install docker on our system a Linux virtual environment is created with its own kernel. Now to when we try to run a docker image, this kernel separates a portion of hardware resources like CPU, Hard Disk, Memory, etc. These portion of hardware resources are totally isolated and only available to the running application. This basically becomes a container. Now, the instance of docker image is loaded into the container's memory and it is started using the docker image's startup command. Have a look at this diagram to get a better understanding. 

 

Here is a video demonstration of installing docker and running an application using docker.

 

Hope after reading this you get a basic understanding of what docker is and how it works. Although there is no hands-on example on how to use docker, but these concepts are necessary before you get started. In the next article, we will build a NodeJS application using Docker, so don't forget to subscribe. Stay Safe and Happy Coding!

Post a Comment

0 Comments