Docker Swarm is Docker's native container orchestration solution, built directly into Docker Engine, that transforms a pool of Docker hosts into a single virtual system. Unlike external orchestrators, Swarm mode leverages familiar Docker concepts and commands while adding cluster management, service discovery, load balancing, and zero-downtime deployments. It uses the Raft consensus algorithm to maintain cluster state across manager nodes, ensuring high availability without external dependencies. Keep in mind that Swarm operates on a declarative model — you define the desired state of services, and the orchestrator continuously works to maintain that state, automatically recovering from failures and distributing workloads.
What This Cheat Sheet Covers
This topic spans 16 focused tables and 154 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Swarm Initialization and Cluster Setup
| Command | Example | Description |
|---|---|---|
docker swarm init --advertise-addr 192.168.1.100 | • Initializes a new swarm cluster on the current node, making it the first manager • generates join tokens for workers and additional managers. | |
docker swarm init --advertise-addr 10.0.0.5:2377 | • Specifies the IP address and optional port that other nodes use to reach this manager • required on multi-interface hosts. | |
docker swarm init --listen-addr 0.0.0.0:2377 | • Defines the interface and port where the manager listens for Swarm traffic • defaults to 0.0.0.0:2377. | |
docker swarm init --autolock | Enables automatic locking of the swarm, requiring an unlock key after manager restart to protect Raft logs and secrets. | |
docker swarm join-token worker | Displays the full join command with token for adding worker nodes to the swarm. | |
docker swarm join-token manager | Displays the full join command with token for adding manager nodes to the swarm. |