Understanding Docker Architecture with examples


Describe Docker

Docker is an open-source container management platform that is free to use and offers a wide range of tools and utilities for developing, testing, and deploying applications. You can build packed, isolated, and platform-independent containers that include all libraries and dependencies. This will make it simple for you to create and distribute applications.

The Docker Platform

The Docker platform provides tools and utilities for packaging, building, and running software applications in isolated and containerized environments known as containers. The Docker architecture's security and isolation enable you to do so.

Docker includes numerous tools for managing container lifecycles.

  • You may construct your apps inside of a pre-built environment that is simple to contain.

  • You may even deploy various components of your application in distinct containers and allow them to communicate and exchange data using Docker networking.

  • That specific container serves as your application's independent unit for testing and distribution.

  • Once your application is up and running, you can quickly deploy it to the production environment utilizing that container or as an orchestrated service.

  • The container offers the same service regardless of whether your host is a cloud service, virtual machine, bare metal server, or a Linux workstation.

Docker’s Workflow

Understanding the components of an effective continuous integration build is crucial. To ensure that our development and build processes go well, do the following steps −

Docker performs all its functions via a client-server architecture. The Docker architecture consists of three main parts, which are as follows −

  • The Docker Daemon (Server)
  • REST API (Docker Engine)
  • Docker CLI (Client)

Together, these elements enable communication between the client and the server. You will observe each of these individually.

Container Daemon

Daemon is a persistent background process that manages all Docker objects, including Images, Containers, Volumes, and Networks. It monitors the Docker API for requests that include instructions, processes them, and takes the appropriate action.

RESTful Docker API

The API works as a go-between between the server and the client. It is used by the client application to communicate with the server (Daemon). Only HTTP clients are able to use the REST API.

Docker Clients

Docker Clients are used to communicate with the Docker daemon. It may be anything as basic as a Command Line Interface. To build and manage Docker objects, you may issue straightforward instructions from the command line (client) to the server directly.

Docker Architecture

The four fundamental components that comprise the Docker architecture are as follows −

  • The Docker Daemon or the server

  • The Docker Command Line Interface or the client

  • Docker Registries

  • Docker Objects −

    • Images

    • Containers

    • Network

    • Storage

Docker Daemon

The Docker daemon, commonly known as 'dockerd,' constantly listens to Docker API requests. The creation and management of Docker objects, such as containers, volumes, pictures, and networks, are only a few of the labor-intensive operations for which it is used. Other daemons on the same or separate host machines can communicate with a Docker daemon. For instance, in a swarm cluster, the daemon on the host system can collaborate with daemons on other nodes to complete tasks.

Docker CLI

Docker users can communicate with Docker using basic HTTP clients such as command line. When a user runs a Docker command, such as Docker run, the CLI sends this request to the dockerd over the REST API. Additionally, the Docker CLI supports multi-daemon communication.

Docker Registries

Dockerhub, the official Docker registry, has multiple official image repositories. A repository includes a collection of comparable Docker images that are distinguished by Docker tags. Dockerhub users have access to a wealth of official and vendor-specific images. Nginx, Apache, Python, Java, Mongo, Node, MySQL, Ubuntu, Fedora, Centos, and others are a few of them.

Using the Docker push command, you may even set up a private repository inside of Dockerhub and store your own Docker images. Docker enables you to use an image named "registry" to build your own private Docker registry on your own system. Once a container connected with the registry image has been launched, you may use the Docker push command to push images to this private registry.

Docker Objects

A Docker user often interacts with Docker objects such as images, containers, volumes, plugins, networks, and so on. You'll get a quick glimpse of each of them below.

Docker Images − Docker Images are read-only templates constructed from many layers of files. Docker images may be created using a simple text file called Dockerfile, which offers instructions for creating Docker images. The first command is a FROM command that may retrieve a base image from any Docker registry. Several instructions are then employed to establish the container environment after this base image layer has been generated. Every instruction creates an additional layer on top of the one before it.

  • Docker Containers − Docker containers are isolated, encapsulated, bundled, and protected application environments that contain all of the packages, libraries, and dependencies needed to run an application. For example, if you construct a container with the Ubuntu image, you will have access to an isolated Ubuntu environment. You may also access the Ubuntu environment's bash and issue commands from there.

  • Networks − You may set up a secure channel so that all of the isolated containers in a cluster can communicate and share data or information. To do this, you may utilize a variety of network drivers and plugins. Any Docker network cluster's communication is built on top of Docker networks. There are five main categories of Docker network drivers. These are.

    • Host Driver − Use the Host driver if you do not need any network separation between the Docker host system and the containers on the network.

    • Bridge Driver − When executing multiple applications in the same host system, the Bridge network driver is typically utilized ,it is default network driver.

    • Overlay Driver − You may use the overlay network driver when using Docker swarm mode to run containers on various hosts on the same network. It enables communication between many swarm services running various multi-container application components.

    • Macvlan − The macvlan driver distributes mac addresses to each container in the network. As a result, each container may function as a stand-alone physical host. The mac addresses are used to direct traffic to the correct containers. This can be useful in situations such as VM setup migration, among others.

  • None − The networking services may only be turned off using the None network driver.

  • Storage − Any data and progress you had within a container are gone as soon as you leave it. A permanent storage solution is necessary to prevent this. To communicate, save, and back up your important data, Docker offers a number of persistent storage choices. These include

    • Volumes − You may utilize folders on your host computer to mount as volumes inside Docker containers. These are in the file system of the host machine, which is outside of the container's copy-on-write mechanism. You may build, manage, list, and delete volumes using a number of Docker commands.

    • Volume Container − You can mount a volume to another container using a specific container.

    • Directory mounts − A local directory on the host computer can be mounted to a container. When it comes to volumes, the directory must be located inside the host machine's volumes folder to be mounted. In contrast, you may quickly mount any directory on your server as a source when using directory mounts.

    • Storage Plugins − By mapping them with the host storage, storage plugins allow you to connect to any external storage platform, such an array, appliance, etc.

Conclusion

You learned about Docker's importance in the field of containerization and its architecture in this article. You also learnt about the major components that make up the Docker architecture, such as the Docker daemon, Docker CLI, and the REST API. You also learned how to fully utilize containerization by utilizing Docker objects including images, volumes, networks, and containers.

Updated on: 27-Feb-2023

185 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements