This article is for those looking for a detailed and straightforward guide on installing Docker Swarm on Ubuntu Server.

Docker Swarm is a clustering tool for Docker that transforms a collection of Docker servers into a single cluster. Docker Swarm ensures availability and high performance by distributing it across Docker servers within the cluster.

In this guide, we will consider the case when you already have a server with the Ubuntu Server 22.04 LTS operating system installed on it.

You can read more about how to install Ubuntu Server 22.04 LTS in my guide “Install Ubuntu Server 22.04 LTS”.

Also, the Docker Engine must be installed on the server.

You can learn how to install Docker Engine and Docker Compose on Ubuntu Server by reading “Install Docker Engine and Docker Compose on Ubuntu Server”.

In addition, OpenSSH must be installed on the server, and port 22 must be open in order to be able to connect to the server using the SSH protocol.

To install OpenSSH on a server, you can use the command:

sudo apt install openssh-server

If you plan to connect to the server using the Windows operating system, you can use PuTTY or MobaXterm.

This guide describes how to connect to a server using the iTerm2 terminal emulator installed on the macOS operating system.

Please note that you will need to open the following TCP and UDP ports to access your server:

  • TCP port 2377 - for cluster management and Raft synchronization.
  • TCP and UDP port 7946 - for communication between all Docker Swarm servers.
  • UDP port 4789 - for network traffic (inbound container network).
  • IP Protocol 50 (ESP) - if you plan to use an encrypted network.

We connect to the server on which you plan to install Docker Swarm.

Let’s see the IP address of the server using the command:

ip a

Install Docker Swarm on Ubuntu Server

We activate Docker Swarm using the command:

docker swarm init --advertise-addr 10.170.18.13

Install Docker Swarm on Ubuntu Server

Please note 10.170.18.13 is the IP address of my server. Accordingly, you need to specify the IP address of your server.

Docker Swarm is activated.

Using the command shown on the screen, you can join another server with the “Worker” role to the Docker Swarm cluster.

Please note that to prepare another server for the Docker Swarm cluster, you need to install only the Docker Engine on the new server and run the docker swarm join command with the appropriate token.

You can learn how to install Docker Engine and Docker Compose on Ubuntu Server by reading “Install Docker Engine and Docker Compose on Ubuntu Server”.

Now we will get the token for joining the new server with the “Manager” role to the Docker Swarm cluster using the command:

docker swarm join-token manager

Install Docker Swarm on Ubuntu Server

Using the command shown on the screen, you can join another server with the “Manager” role to the Docker Swarm cluster.

Please note that to prepare another server for the Docker Swarm cluster, you need to install only the Docker Engine on the new server and run the docker swarm join command with the appropriate token.

Now you need to make sure that Docker Swarm is installed correctly. To do this, you need to run the command:

docker info

Judging by the message received, Docker Swarm is installed correctly.

Install Docker Swarm on Ubuntu Server


My Courses

🎓 Dive into my comprehensive IT courses designed for enthusiasts and professionals alike. Whether you’re looking to master Docker, conquer Kubernetes, or advance your DevOps skills, my courses provide a structured pathway to enhancing your technical prowess.

My Services

💼 Take a look at my service catalog and find out how we can make your technological life better. Whether it’s increasing the efficiency of your IT infrastructure, advancing your career, or expanding your technological horizons — I’m here to help you achieve your goals. From DevOps transformations to building gaming computers — let’s make your technology unparalleled!

Refill My Coffee Supplies

💖 PayPal
🏆 Patreon
💎 GitHub
🥤 BuyMeaCoffee
🍪 Ko-fi

Follow Me

🎬 YouTube
🐦 Twitter
🎨 Instagram
🐘 Mastodon
🧵 Threads
🎸 Facebook
🧊 Bluesky
🎥 TikTok
🐈 GitHub

Is this content AI-generated?

Nope! Each article is crafted by me, fueled by a deep passion for Docker and decades of IT expertise. While I employ AI to refine the grammar—ensuring the technical details are conveyed clearly—the insights, strategies, and guidance are purely my own. This approach may occasionally activate AI detectors, but you can be certain that the underlying knowledge and experiences are authentically mine.

Vladimir Mikhalev
I’m Vladimir Mikhalev, the Docker Captain, but my friends can call me Valdemar.

Recent Posts

DevOps Community

hey 👋 If you have questions about installation or configuration, then ask me and members of our community: