Install Docker Swarm on Ubuntu Server
By Vladimir Mikhalev · Solutions Architect · Docker Captain · IBM Champion
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.
TIPArchitecture 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.
IMPORTANTDocker 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
IMPORTANTOpenSSH 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:
sudo apt install openssh-serverNOTETo connect to the server from a Windows system, you can use tools like PuTTY or MobaXterm.
NOTEThis guide walks you through connecting to a server with the iTerm2 terminal emulator on macOS.
CAUTIONYou 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:
ip a
Now initialize Swarm:
docker swarm init --advertise-addr 10.170.18.13
NOTE10.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.
NOTETo 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 joincommand with the appropriate token.
NOTEFor 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:
docker swarm join-token manager
Same idea as before. The printed command joins another server to the cluster, this time with the manager role.
NOTETo 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 joincommand with the appropriate token.
One last check. Confirm Swarm is actually running:
docker info
The message back confirms it. Swarm is installed and working.
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
- 1Terraform MCP server GA: the Apply Gate your auditor will ask aboutDevOps & 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.
- 2Docker supply chain hardening — from Scout D to OpenSSF 7.8 on a 730K-pull imageDevOps & Cloud · How I hardened a 730K-pull public Docker image from Scout grade D to OpenSSF Scorecard 7.8. Multi-stage build, cosign signing, SLSA provenance, non-root default, and the incident that changed how I ship attestations.
- 3Cloudflare Web Analytics on Astro — Why Removing GA4 Unlocked Lighthouse 100DevOps & Cloud · How removing Google Analytics 4 from an Astro site unlocked Lighthouse 100, why Cloudflare Web Analytics replaced it, and what the tradeoffs actually cost.
- 4Platform Engineering — The Complete, Practical Guide to Building Internal Developer Platforms That ScaleDevOps & Cloud · A deep, practical guide to Platform Engineering. Learn how to build internal developer platforms, golden paths, GitOps workflows, and scalable cloud foundations.
Random Posts
- 1Install Nextcloud with OnlyOffice Using Docker ComposeSelf-Hosting · Step-by-step guide to installing Nextcloud with OnlyOffice using Docker Compose. Includes Traefik, Let's Encrypt, secure document editing, and cloud storage.
- 2Install Exchange Server 2010SysAdmin & IT Pro · Step-by-step guide to install Exchange Server 2010 on Windows Server 2008 R2. Includes prerequisites, AD setup, and full installation walkthrough.
- 3Streamlining Security in Software Development with SnykDevOps & Cloud · Discover how Snyk integrates into DevOps to improve app security—from code to containers. Secure your development workflow with this powerful tool.
- 4Restore Windows Firewall DefaultsSysAdmin & IT Pro · Learn how to restore Windows Firewall to its default settings using GUI, Command Prompt, or PowerShell. Step-by-step guide for Windows system admins.