docker version: 20.10+ - Date: June 2022
Cluster initialization
On the first Manager node
Initialize the clusterdocker swarm init --advertise-addr MANAGER-IP
Retrieve the token to add a new Manager nodedocker swarm join-token manager
Retrieve the token to add a new Worker nodedocker swarm join-token worker
On every new node
Join the node to the clusterdocker swarm join --token TOKEN
Cluster events
Show real time events
docker events
Manage networks
Create a distributed overlay network
docker network create --driver overlay NETWORK
Manage nodes
List all nodesdocker node ls
Inspect a nodedocker node inspect NODE
List tasks running on a node
docker node ps NODE
Promote a node to Managerdocker node promote NODE
Demote a node to Workerdocker node demote NODE
Update a nodedocker node update [options] NODE
- Add a label:
docker node update --label-add type=front node-1
- Drain a node:
docker node update --availability drain node-1
Make a Worker node leave the Clusterdocker swarm leave
Remove a node from nodes listdocker node rm NODE