541 words
3 min read

Install Docker Swarm on Ubuntu Server

By · Solutions Architect · Docker Captain · IBM Champion
Install Docker Swarm on Ubuntu Server

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.

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 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:

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.

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:

Terminal window
ip a

Install Docker Swarm on Ubuntu Server - Step 1

We activate Docker Swarm using the command:

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.

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.

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

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

Terminal window
docker swarm join-token manager

Install Docker Swarm on Ubuntu Server - Step 3

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

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.

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

Terminal window
docker info

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

Install Docker Swarm on Ubuntu Server - Step 4


Vladimir Mikhalev

Docker Captain  ·  IBM Champion  ·  AWS Community Builder

The Verdict — production-tested analysis on YouTube.

Related Posts

Same category
  1. 1
    Docker supply chain hardening — from Scout D to OpenSSF 7.8 on a 730K-pull image
    DevOps & 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.
  2. 2
    Cloudflare Web Analytics on Astro — Why Removing GA4 Unlocked Lighthouse 100
    DevOps & 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.
  3. 3
    Platform Engineering — The Complete, Practical Guide to Building Internal Developer Platforms That Scale
    DevOps & Cloud · A deep, practical guide to Platform Engineering. Learn how to build internal developer platforms, golden paths, GitOps workflows, and scalable cloud foundations.
  4. 4
    Amazon Q vs DevOps Chaos — Can This AI Fix AWS Faster Than You?
    DevOps & Cloud · Fix AWS issues faster with Amazon Q, the AI assistant built for DevOps. Real-world examples, limitations, and how it compares to ChatGPT.

Random Posts

Random
  1. 1
    Amazon Q vs DevOps Chaos — Can This AI Fix AWS Faster Than You?
    DevOps & Cloud · Fix AWS issues faster with Amazon Q, the AI assistant built for DevOps. Real-world examples, limitations, and how it compares to ChatGPT.
  2. 2
    Install Terraform on macOS
    DevOps & Cloud · Learn how to install Terraform on macOS using Homebrew. Step-by-step guide includes setup, version check, and usage tips for managing infrastructure as code.
  3. 3
    The Fates of Famous Figures Under the Pressure of Power from the Russian Empire to Our Days
    Opinion & Culture · Explore the lives of famous figures persecuted by Russian regimes—from the Empire to today. Discover stories of censorship, exile, and resistance.
  4. 4
    Install Quake 3 Server Using Docker Compose
    Self-Hosting · Deploy a Quake 3 server with Docker Compose on Ubuntu Server. Fast setup, WebGL-ready, browser access via QuakeJS, plus full configuration steps.
Install Docker Swarm on Ubuntu Server
https://heyvaldemar.com/install-docker-swarm-on-ubuntu-server/
Author
Vladimir Mikhalev
Published
2020-12-26
License
CC BY-NC-SA 4.0