Docker Swarm

Docker swarm allows the running of a docker container across a cluster of nodes and manages those containers as a single unit.

There are two types of nodes in Docker Swarm:

  1. Manager node: The manager node distributes tasks to worker nodes. 
  2. Worker node: completes the tasks given by the manager node.

task carries a Docker container and the commands to run inside the container.  It is the atomic scheduling unit of the swarm. The swarm manager node constantly checks the state of the cluster and ensures it is always equal to the actual state specified by the user. For example, if a service specifies running 3 replicas of a container and 1 of the containers crashes, the swarm manager node will assign the new replica to one of the available nodes in the cluster.

How to Use Docker For Fault Tolerance with Docker Replicas?

Docker is a set of platform-as-a-service products that use OS-level virtualization to deliver software in packages called containers. A cluster of docker engines is called a swarm. Docker Swarm is a cluster management and orchestration feature embedded in the Docker Engine.

Similar Reads

Docker Replicas

Docker replicas refer to running multiple instances of a docker container to ensure high availability, scalability, and load balancing. Docker replicas allow you to scale your application stack by creating multiple instances of a service....

Docker Swarm

Docker swarm allows the running of a docker container across a cluster of nodes and manages those containers as a single unit....

Docker Service

The main building block of the docker swarm is a service. A docker swarm service is a group of Docker containers managed together. In a service, you specify the image to be used and the commands to run inside the running container. You can also specify other info such as the number of replicas of an image to run, and the port to which the service will be available outside the swarm. Docker swarm breaks the service into one or more tasks based on the replicas value. One task in the docker swarm corresponds to exactly one running container....

Docker Compose

Docker compose is a tool for defining and running multi-container docker applications. In compose you create a YAML file defining all the services that are needed in your application, along with the image, ports, environment variables, network, and volumes associated with each service. For example, you might describe an application comprised of a web front-end service with message queueing services and a database backend....

Enable Docker Swarm

To enable docker swarm in your machine to run multiple instances of container for fault tolerance you need to run the following command:...

YAML File creation

Below is a simple docker-compose.yml file:...

Deploy Containers

...

Scale

To deploy the above file in the docker swarm you need to use the below command:...

FAQs on Docker Swarm

Now if you want to create more containers you can use the below command:...