How to Setup and Configure Docker Swarm Cluster

In this tutorial, you will learn how to set up a four node docker swarm cluster.


  • Minimum two nodes with Docker installed ( swarm manager and cluster nodes)
  • All the nodes should be able to talk to each other using public or private IP addresses.

In this setup, I have total 4 nodes. 1 Swarm manager node and three other nodes to join the cluster with the following private IP addresses

Follow the steps given below for a multi node swarm cluster.

On Manager Node

1. Execute the following command with the manager nodes IP for initializing the swarm cluster.

For example,

You will get the following output once swarm is initialized.

As you can see, the output has the steps to join other nodes to this swarm manager node.

READ  Jenkins Tutorial For Beginners - Getting Started Guide

2. To know the swarm cluster info, execute the following command.

In the output, you will see the following.

3. To know the information about all the nodes in the cluster, you can run the following command.

On Node 1, 2 and 3

Now that we have the swarm manager ready, we can add our other nodes to the manager to form a multi node cluster.

1. Execute the swarm join command from the manager output on all the extra nodes as shown below. The swarm token and IP will change based on your environment.

Note: You can get the swarm token with the command by executing docker swarm join-token worker on the manager node.

Swarm Configuration and Testing

1. Once you joined all the extra nodes, you can list the swarm node information by executing the following command on the manager node.

You will get the output will the swarm cluster info as shown below.

Now our cluster is ready. You can start deploying applications to your swarm cluster.

ONLINE COURSE:  Docker Mastery: The Complete Toolset From a Docker Captain

Check out the docker course which thousands of students have already enrolled.

  • Learn Docker and Compose
  • Best practices for making Dockerfiles
  • Learn to build multi node swarm cluster
  • Rolling application deployments without downtime


Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.