Skip to content

Create a Docker Swarm on Ubuntu 22.04

By Patrick Domingues2 min read
Docker Tutorials

Create a Docker Swarm with an explicit node, network and recovery plan. Validate cluster membership and a disposable service before entrusting stateful workloads to the cluster.

Prepare a private cluster network

Use supported Docker Engine installations on the Ubuntu 22.04 nodes and decide which nodes are managers and workers. Plan stable management addresses, workload storage, manager quorum and recovery before treating a cluster as highly available.

Follow Docker’s Swarm networking requirements. Restrict management, node discovery and overlay traffic to trusted cluster nodes. The default management port is TCP 2377; node communication uses TCP/UDP 7946, and the default overlay data path uses UDP 4789. Do not expose cluster data-path ports directly to untrusted networks.

Initialize the intended manager

On the designated test manager, replace the example address with its verified private address:

docker swarm init --advertise-addr 192.0.2.10

This changes that Engine into a manager. The documentation-range address is a placeholder, not a route to use unchanged. Record the output securely; join tokens grant access to the cluster and must not be published in scripts or screenshots.

Join and inspect workers

Obtain the worker join command from the manager and execute it only on approved worker nodes. Confirm every node’s identity and health from a manager:

docker node ls

Joining a node does not replicate application data volumes or establish a backup. Prepare the application’s storage and secrets separately before deploying stateful services.

Deploy a test service and verify behavior

Use an approved image and explicit service configuration. Inspect desired versus running tasks, service logs, published-port behavior and network access. Scaling replicas does not guarantee zero downtime; the application, health checks and update settings determine what clients experience.

For a failure exercise, use a disposable cluster and confirm the intended manager and workload recovery. Keep a rollback plan and collect evidence before applying the design to production.

Maintain the cluster deliberately

Review membership and rotate exposed join tokens through Docker’s documented workflow. Back up Swarm state and workload data using appropriate procedures. Drain and remove nodes carefully when decommissioning them.

The old generic docker swarm leave --force teardown example has been removed. Forcing a manager out of an active cluster is not a harmless cleanup command and can damage availability or recoverability.

Practical checks and next steps

Test manager availability and workload recovery deliberately. Replicas, routing and local container volumes do not by themselves guarantee zero downtime or recoverable application data.

Explore Virtualization & Containers for related guides.

Reference 1 Reference 2 Reference 3

Content review: November 24, 2026. Reviewed the stated scope, guidance and source references; tenant, hardware and production changes were not executed as part of this editorial review. Original publication date retained.

Patrick Domingues, arms crossed

Patrick Domingues

Practical cybersecurity insights, IT tutorials, and tools for the systems you manage every day.

Leave a Reply

Your email address will not be published. Required fields are marked *