Docker and Containerization

Life before containerization:

Before containers were even a concept, software developers used to manage the code on their physical machines and then deploy it to the production environment. The problem with it was that the performance was getting degraded in the production environment when deploying the code from the local environment.

Suppose an application is loaded on a developer's local machine, then it will be running fine, but when the same code is deployed to the production environment there are problems like the code might get burst or the web server is unable to handle the requests, etc. For all the above-mentioned problems containerization was introduced.

What exactly is Docker?

It is a containerization tool that is used to deploy containers across different environments and they can be transported to any operating system as well. This helps in solving the problems of inconsistency. As the containers can be run on all the operating systems in all environments, the containers remain consistent.

Containers Vs Virtual Machines

The basic difference between using a container as compared to a Virtual machine is that if we are running applications on a virtual machine, a guest operating system is required, which is managed by a hypervisor. The hypervisor manages and allows for the creation of multiple virtual machines on the host operating system.

In a Virtual Machine, the Guest OS is divided evenly between all the VMs, whereas if we look at containerized applications,

we can see the host OS is common for all the container applications.

Docker Architecture

The main components of docker architecture are

  • Docker Client

    It is the way to interact with the Docker to communicate with the Docker daemon. When we run a docker run command on the terminal, the terminal sends these commands to the docker daemon.

  • Docker Host

    It is the system that acts as the primary environment for managing and executing Docker containers. It is used to provide an environment to execute and run applications.

    It contains the docker daemon, images, and containers.

    1. Docker Daemon

      The Docker daemon listens for Docker API requests and manages

      Docker objects such as images, containers, networking, and storage. A

      daemon can also communicate with other daemons to manage Docker services.

    2. Docker Image

      A Docker image is a read-only template that includes all the necessary components for running an application, such as code, libraries, and configuration files. Images are created using a Dockerfile, which is a text file specifying the steps required to build the image.

    3. Dockerfile

      A Dockerfile is a text file that contains a set of instructions and commands used to build a Docker image. It serves as a blueprint or recipe for creating a Docker image that encapsulates an application or service.

    4. Docker Container

      A Docker container is a runnable instance of an image. When you run a

      container, it involves the creation of a new process by Docker, that runs in

      isolation from the rest of the system. This isolation enables the concurrent

      execution of multiple containers in a single machine without any

      Cross-interference.

  • Registry

    A Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured to look for images on Docker Hub by default. You can even run your private registry.

This was all for this tutorial.