History of Virtualization
Not so long ago from now, deploying a service was a process that was both slow and painful. The process involved the writing of code by the development team and then its deployment by the operations team on metal machines. The operations team used to have their work cut out as they had to look for language compilers, libraries, and patches to make the code work.
If the process had any errors or bugs, it would have to start all over again – the development team would fix the bugs or errors, and the operations team would again begin deploying the code.
Things got a little better when Hypervisors were developed. So, what are Hypervisors? These are a collection of virtual machines (VMs) that may be continuously be running or switched off at regular intervals, especially when not in use. Virtual machines definitely helped by accelerating the process of the fixing of errors and the deployment of code, but they still had a few issues. Docker containers came as the real game-changers. They even addressed the issues that existed in virtual machines.
What is Docker?
It is an open-source platform that is used by developers across the globe to run, package, and distribute applications. Docker makes the process of the encapsulation of applications from the first step to the last, very easy and efficient. To understand Docker in a better manner, you will have to understand what containers are and how they work.
A container is nothing but a stand-alone, lightweight, and executable package of a part of the software that comes with everything that is required to run it. Containers are in no way dependent on platforms. So, Docker is compatible both with Windows and Linux-based machines. Also, you can even run Docker on a virtual machine, if the need arises. The basic objective that Docker aims to achieve is to let developers use distributed architecture to run microservice applications.
Unlike virtual machines that used to perform the abstraction of hardware, Docker goes a level up and performs abstraction of a different set of resources at the OS level. This provides several benefits, including separation of infrastructure and portability of applications amongst others. In other words, unlike virtual machines that used to abstract the hardware server, Docker’s container-based approach works by abstracting the OS core. This is a great alternative to virtualization that leads to the faster creation of lightweight instances. Docker is available in two versions:
Enterprise Edition (EE):
This version is specifically designed for IT teams and enterprise development. This version is used to develop, ship, and run applications.
Community Edition (CE):
This version is used by individuals and small teams that are exploring container-based apps or getting started with Docker.
In this section, we will focus on the Docker Engine as well as its different components. This will help us in better understanding how Docker works before we move on to Docker architecture. Docker Engine is the power that enables developing to perform various functions using this container-based app. You can use the components that are listed below to build, package, ship, and run applications.
1. Docker Daemon
It is the background process that continuously works to help you manage images, storage volumes, networks, and containers. It is always looking for Docker API requests to process them.
2. Docker CLI
It is an interface client that interacts with Docker Daemon. It helps developers simplify the process of managing container instances. It is one of the primary reasons why developers prefer Docker over other similar applications.
3. Docker Engine Rest API
It facilitates interactions between Docker daemon and applications. An HTTP client is usually required to access these APIs.
Docker architecture is a client-server based architecture. It has three major components that are mentioned below:
- Docker host
- Docker client
- Docker registry
- Docker objects
In the initial phase, the Docker client interacts with the daemon, which is responsible for performing much of the work that goes into developing, running, and distributing Docker containers.
Docker daemon and the client can either run on a single system or the developer can use a remote daemon to connect it with a local Docker client. Rest API is used to establish communication between Docker daemon and client. This can be either done over a network interface or UNIX sockets.
Let’s now discuss Docker architecture components in detail.
Also read: Why Become a Full Stack Developer?
1. Docker Host
A Docker host is responsible for running the Docker daemon. Docker Daemon entertains API requests, including docker build and docker run amongst others. It also manages images, networks, containers, and other Docker objects. Daemons can communicate with each other to manage different Docker services.
2. Docker Client
It is nothing but the method that users use to interact with Docker. The Docker client sends our requests, such as docker run, and Docker builds to Docker daemon. A very important feature of Docker client is that it can communicate with several daemons.
3. Docker Registry
A registry is a server-side application that is scalable and stateless. It not only stores Docker images but lets developers distribute them as well. Docker provides us with the flexibility to create our own images, or there are public registries available that we can make use of. These registries include Docker Cloud and Docker Hub amongst others.
Docker’s configuration is such that it always turns to Docker Hub and other public registries to look for images. However, we have the option of creating our own registry. So, we can pull out the required images using our own registries with the help of docker run and docker pull commands. Docker push command pushes the required image to the registry that we created.
4. Docker Objects
We use and create several objects while using Docker. These objects include containers, images, plugins, volumes, networks, and others.
5. Docker Images
A Docker image is nothing but a read-only template that provides us with the instruction required to create a container. On many occasions, one image has a connection with another image. What differentiates two images is the added layer of customization. To put it differently, an image can also be defined as an immutable snapshot of a container. Images are small, lightweight, and fast.
6. Docker Containers
Let’s follow a different approach to understand Docker containers. So, if an image could be used for representing a class, a container could be its instance. In other words, a container is a runtime object. We can create, start, move, stop, or delete containers with the help of Docker CLI or API. Containers can also be attached to storage and connected to one or more than one network. Depending on the current state of a container, we can also create a new image.
Now that you know what Docker architecture and its components are, you are in a better position to understand the rise in its popularity. It simplifies infrastructure management and helps make instances faster, lighter, and more resilient.
If you’re interested to learn more about full stack coding, check out upGrad & IIIT-B’s PG Diploma in Full-stack Software Development which is designed for working professionals and offers 500+ hours of rigorous training, 9+ projects, and assignments, IIIT-B Alumni status, practical hands-on capstone projects & job assistance with top firms.