docker-swarm
Orchestrate and manage a cluster of Docker nodes
TLDR
Initialize a swarm cluster
Display the token to join a manager or a worker
Join a new node to the cluster
Remove a worker from the swarm (run inside the worker node)
Display the current CA certificate in PEM format
Rotate the current CA certificate and display the new certificate
Change the valid period for node certificates
SYNOPSIS
docker swarm [COMMAND] [OPTIONS]
PARAMETERS
init
Initialize a swarm cluster on the current node, making it a manager.
join
Join the current node to an existing swarm as a manager or worker.
join-token
Manage join tokens for worker or manager nodes.
leave
Leave the swarm (force with --force).
unlock
Unlock a locked swarm using the unlock key.
unlock-key
Manage the unlock key for a locked swarm.
update
Update swarm configuration (e.g., autolock).
--help
Show help for docker swarm.
DESCRIPTION
Docker Swarm is Docker's native clustering and orchestration solution for running containerized applications across multiple hosts. The docker swarm command enables initialization, joining, and management of swarms, which are groups of Docker nodes working together as a single system.
In Swarm mode, nodes are either managers (handling orchestration) or workers (running tasks). Use docker swarm init to create a single-node swarm on the manager. Other hosts join via docker swarm join with a generated token. Services deployed with docker service create are automatically scheduled, scaled, and maintained across the cluster, with built-in load balancing, rolling updates, and failover.
Key features include service discovery, routing mesh, secrets management, and config objects. This command supports multi-manager setups for high availability. Swarm integrates seamlessly with Docker Compose via docker stack deploy. Ideal for production workloads requiring resilience without external orchestrators like Kubernetes.
CAVEATS
Only one swarm per host; requires Docker 1.12+; manager nodes store Raft logs (avoid resource-constrained hosts); deprecated external CA support in newer versions.
BASIC USAGE EXAMPLES
docker swarm init --advertise-addr 192.168.1.10
docker swarm join --token SWMTKN-1-... 192.168.1.10:2377
KEY OPTIONS (COMMON)
init: --autolock, --listen-addr
join: --token, --role
update: --autolock
HISTORY
Introduced in Docker 1.12.0 (July 2016) replacing deprecated Docker Machine cluster. Evolved with multi-manager HA, overlay networking v2, secrets (1.13), and autoscaling support.
SEE ALSO
docker(1), docker-node(1), docker-service(1), docker-stack(1)


