Introduction

Let me take you back to the first time I set up a Docker Swarm cluster. I had two laptops, a Raspberry Pi, and more enthusiasm than experience. I imagined a smooth orchestration setup in minutes. Spoiler alert: it took a few more than "a few" minutes. But the learning I gained from getting it working was priceless.

Setting up a Swarm is often seen as the technical turning point where curiosity meets hands-on implementation. You’ve read about what Docker Swarm can do—now it’s time to bring it to life.

This chapter walks you through everything you need to build your own Swarm cluster from scratch, even if you’ve never done it before. We’ll keep the commands simple, the language friendly, and the goals clear. Whether you’re on a personal laptop or spinning up cloud instances, by the end of this chapter, you’ll have a functional Docker Swarm cluster—and the confidence to deploy on it.

Prerequisites: What You Need Before You Swarm

Let’s start with the basics. You don’t need a data center or a dozen servers to follow along. You just need:

Tools You Need:

Tip: For testing, you can create multiple VMs on a single machine using VirtualBox and VMware Workstation or even use tools like Docker Machine or Multipass.

Steps to create a Swarm Cluster

Now, the fun begins. We'll build the cluster piece by piece.

Let’s say you have:

Let’s start by initializing the manager.

Step 1. Initialize the Swarm on the Manager Node

Log in to your manager node and run:

​​​​​​​docker swarm init --advertise-addr <MANAGER-IP> 

Replace <MANAGER-IP> with the actual IP address of the manager node (like 192.168.0.114).

This command:

You’ll see an output like this:

Swarm initialized: current node (xxxxxxx) is now a manager.

To add a worker to this swarm, run the following command:

docker swarm join \
--token SWMTKN-1-xxxxx-xxxxx \
192.168.0.114:2377

Make a note of that join command, you’ll use it on your worker nodes.

Step 2. Join the Workers to the Swarm

Now, SSH into worker-node-1 and worker-node-2 and run the join command you got earlier:

docker swarm join \
--token SWMTKN-1-xxxxx-xxxxx \
192.168.0.114:2377

Each node will respond with:

This node joined a swarm as a worker.

Boom. You’ve got yourself a multi-node Swarm cluster.

Step 3. Verify the Cluster

Back on your manager node, run:

docker node ls

This lists all nodes in the Swarm:

You’re the proud owner of a working Swarm. Pat yourself on the back—this is a big milestone!

Swarm Init and Join Commands Explained

Let’s break down the key commands used here—because understanding them helps you troubleshoot later.

docker swarm init

This command

The --advertise-addr flag is crucial. It tells other nodes where to find the manager.

Pro Tip: Always use a static IP or DNS for your manager node, especially in production environments.

The join token

When you ran swarm init, Docker generated a secure join token. This token:

You can retrieve the token anytime using:

docker swarm join-token worker
docker swarm join-token manager

This is great for scaling your cluster dynamically.

Mistakes to Avoid

Let’s talk about what can go wrong—because it probably will at some point.

Real-World Example: Building a Mini Dev Cluster

In one of my earlier projects, I had to build a lightweight dev environment for testing microservices. Instead of using Kubernetes (which was overkill for our needs), I used Docker Swarm.

I set up:

This article demonstrates a Docker Swarm setup using Proxmox VE as the virtualization platform. Three VMs are configured: one as the Docker manager node and two as worker nodes. The environment is ideal for practicing container orchestration and service deployment in a clustered setup.

The entire setup took 15 minutes. I could deploy stacks, perform rolling updates, and manage services with ease—all from one CLI. And it was lightweight, fast, and cheap.

For small-to-medium-sized projects, Swarm is a dream.

Conclusion

You did it, you set up a working Docker Swarm cluster!

Let’s recap what you’ve learned:

At this point, you're not just reading about orchestration—you’re doing it. You’ve built the foundation for running distributed apps, scaling containers, and deploying services reliably.