What is Docker.Why we need it?

What is Docker.Why we need it?

Table of contents

Docker was born in 2013. It is an open-source containerization tool that allows developers to create, ship, and run applications in containers. But what is a container?

Actually container is a lightweight and portable virtual environments that package everything an application needs to run like its source code, runtime, system tools, libraries,etc. This container can be easily deployed and run consistently across various environments, whether it's a developer's local machine, a testing server, or a production server in the cloud like AWS,GCP and AZURE.

Before Docker, developers faced frustrating situations where their code worked perfectly on their development machines but failed when deployed to other environments. This problem was due to differences in the underlying systems, dependencies, and configurations. Docker solved these problems by ensuring that the entire application environment will be identical across all stages of the development and deployment lifecycle.

Docker Architecture:-

Docker Architecture diagram

From the above Picture let us understand its architecture:-

  1. Docker Client: The Docker client is the way users interact with Docker.

    It provides a command-line interface (CLI) that allow users to communicate with the Docker daemon, instructing it to perform specific tasks, like building images, running containers etc. The Docker client can communicate with more than one daemon.

  2. Docker Host: Docker host is a mechine where we install Docker. If i install docker on my windows laptop then i can call this windows laptop as docker host because it become a host for Docker.

  3. Docker Daemon: At the heart of the Docker architecture lies Docker daemon, also known as the Docker engine or dockerd. It is responsible for managing Docker objects like containers, images, networks, and volumes. The daemon listens for Docker API requests and executes them, making Docker operations possible.

  4. Docker Registry: Docker registry is a repository which stores Docker images. Docker Hub is the default public registry provided by Docker.Here we can find lots of images.

    Defining Docker Objects:-

  5. Docker Image:

    ✔️Images are the building blocks of containers.

    ✔️A Docker image is executable software package that contains an application and all its dependencies (libraries, code, runtime, system tools, etc.) needed to run.

    ✔️Images are created using Dockerfiles. which contain instructions on how to build the image. Each instruction in a Dockerfile creates a layer in the image. When you change the Dockerfile and rebuild the image, only those layers which have changed are rebuilt. This is part of what makes images so lightweight, small, and fast, when compared to other virtualization technologies.

    ✔️We pull Images into local mechine by "docker pull <image name>" command from image hub know as Docker registery.It is a public docker image hub.

  6. Docker Container: When an image is executed comes into running condition know as container.OR Container is a running instance of image.This is done by "docker run <image name>" command.