Trusted answers to developer questions

What is Docker Swarm?

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

widget

What is Docker Swarm?

Docker is a containerization system that enables developers and teams to handle containers that can be used in application deployment.

However, Docker is a single node that may only be able to support a certain number of containers. But what if the developer team requires the deployment of thousands of containers?

This where the concept of Docker Swarm comes in. A Docker Swarm is the virtualization of several Docker nodes (running Docker Engine) clustered together. Nodes in these clusters can communicate with each other and allow developers to manage numerous nodes in a single ecosystem.

Docker Swarm Architecture

svg viewer

In a Docker Swarm, there is a Docker Manager and several Docker Workers.

Docker Manager

A Docker Manager has complete control over what a Docker Worker does. Docker Manager assigns, controls, and manages the task appointed to each Docker Worker. Moreover, it keeps track of the status of all its workers. Docker Manager knows the task the worker is on, the task assigned to it, how the tasks are distributed among all the workers, and whether or not the worker is up/active.

The Docker Manager lets us create a new service and orchestrate it via its API. Then, it allocates workers to tasks using the IP addresses of different workers under its domain.

Note: There can be multiple Docker Managers. In such a scenario, there will be one primary manager and the rest will be secondary managers. All the manager nodes will elect this primary manager. While the secondary managers will be able to assign tasks and monitor workers, the primary manager reserves the power of control over all the worker nodes and secondary managers.

Docker Worker

A Docker Worker is entirely under the control of the Docker Manager. The Docker Worker accepts the tasks/instructions assigned to it by the Docker Manager and executes it. A Docker Worker consists of a client agent who communicates the status of the node to the manager. These communications are through REST API over HTTP.

Docker Daemon

The Docker Daemon listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. It runs on your host operating system.

Fault Tolerance

svg viewer

In case a Docker Worker fails, the containers on that node are rescheduled to another node.

In case a Docker Worker fails, there is a Backup Folder that has all the data in it. This Backup Folder can be used to restore the swarm with a new Docker Manager.

Docker Swarm provides high availability of resources.

RELATED TAGS

docker
docker swarm
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?