483 words
2 min read

Install Docker Swarm on Ubuntu Server

By · Docker Captain · CNCF Ambassador · IBM Champion
Cover image for the post 'Install Docker Swarm on Ubuntu Server'

This is a straight, detailed walkthrough for getting Docker Swarm running on Ubuntu Server. No filler.

Docker Swarm is Docker’s own clustering tool. It takes a set of Docker servers and turns them into one cluster. The point is availability and performance: Swarm spreads the load across every Docker server in the cluster.

TIP

Architecture Context

Choose Docker Swarm when you need simple container orchestration with minimal operational complexity and built-in Docker integration. Amazon ECS, EKS, or GKE provide managed alternatives with richer ecosystem support. Swarm is justified for small-to-medium deployments where Kubernetes complexity is not warranted, or when your team’s Docker Compose expertise should transfer directly to orchestration.

IMPORTANT

Docker Engine and Docker Compose must be installed on the server.

For a step-by-step guide on installing Docker Engine on Ubuntu Server, see Install Docker Engine and Docker Compose on Ubuntu Server

IMPORTANT

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

Need OpenSSH? Install it with:

Terminal window
sudo apt install openssh-server
NOTE

To connect to the server from a Windows system, you can use tools like PuTTY or MobaXterm.

NOTE

This guide walks you through connecting to a server with the iTerm2 terminal emulator on macOS.

CAUTION

You will need to open the following TCP and UDP ports for access to the services:

  • 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.

First, connect to the server where Swarm will live.

Find the server’s IP address:

Terminal window
ip a

Install Docker Swarm on Ubuntu Server - Step 1

Now initialize Swarm:

Terminal window
docker swarm init --advertise-addr 10.170.18.13

Install Docker Swarm on Ubuntu Server - Step 2

NOTE

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

That’s it. Swarm is up.

The output prints a command. Run that command on another server and it joins the cluster as a worker.

NOTE

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.

NOTE

For a step-by-step guide on installing Docker Engine on Ubuntu Server, see Install Docker Engine and Docker Compose on Ubuntu Server

Workers are one thing. You also want to be able to add more managers. Grab the manager join token:

Terminal window
docker swarm join-token manager

Install Docker Swarm on Ubuntu Server - Step 3

Same idea as before. The printed command joins another server to the cluster, this time with the manager role.

NOTE

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.

One last check. Confirm Swarm is actually running:

Terminal window
docker info

Install Docker Swarm on Ubuntu Server - Step 4

The message back confirms it. Swarm is installed and working.


Vladimir Mikhalev

Docker Captain  ·  CNCF Ambassador  ·  IBM Champion

The Verdict — production-tested analysis on YouTube.

The Verdict

Inconvenient truths about shipping in the AI era

Container security, platform engineering, and the agentic shift — tested in production, argued without the hype. The verdict reaches your inbox the moment there's one worth sending.

Related Posts

Same category
  1. 1
    Restore Drills on a Clean Machine — Measured RTO for 47 Stacks, 19 Seconds to 7 Minutes
    DevOps & Cloud · Restore drills that measure RTO on a machine that never ran the stack, 47 templates weekly. Every same-host restore passed. The first clean one answered 500.
  2. 2
    Mutation Testing for Infrastructure Code — 153 Planted Bugs, Four Tests That Could Not Fail
    DevOps & Cloud · Mutation testing for infrastructure code, done by hand across fifteen repositories. 153 planted bugs, and four green tests that could never have failed.
  3. 3
    Docker Health Checks That Cannot Fail — Seventeen Hours Green
    DevOps & Cloud · A Docker health check whose pattern matches the shell running it can never go red. How to find the checks in your fleet that never failed, and prove each one.
  4. 4
    Terraform MCP server GA: the Apply Gate your auditor will ask about
    DevOps & Cloud · HashiCorp's Terraform MCP server is GA and IBM Bob can write production IaC. ENABLE_TF_OPERATIONS separates a safe assistant from autonomous apply.

Random Posts

Random
  1. 1
    Install Wiki.js with Docker Compose
    Self-Hosting · Step-by-step guide to install Wiki.js with Docker Compose on Ubuntu using Traefik, Let's Encrypt, and PostgreSQL. Secure setup with SSH and HTTPS.
  2. 2
    Leveraging null_resource in Terraform for Complex Operations
    DevOps & Cloud · Master Terraform's null_resource to automate complex DevOps workflows. Learn triggers, local execs, and when to use terraform_data in modern IaC.
  3. 3
    Mastering GitLab CI/CD with Advanced Configuration Techniques
    DevOps & Cloud · Unlock powerful GitLab CI/CD strategies with expert YAML configurations. Learn best practices for pipelines, automation, and secure DevOps deployments.
  4. 4
    Join Windows Server 2019 Server Core to a Domain
    SysAdmin & IT Pro · Step-by-step guide to joining Windows Server 2019 Server Core to a domain using PowerShell. Ideal for IT pros managing Active Directory environments.
Install Docker Swarm on Ubuntu Server
https://heyvaldemar.com/install-docker-swarm-on-ubuntu-server/
Author
Vladimir Mikhalev
Published
2020-12-26
Updated
2026-06-12
License
CC BY-NC-SA 4.0