Docker: Swarm mode (services & stacks)
10 Docker commands: Swarm mode (services & stacks). Click a command to see what each part does.
Docker: Swarm mode (services & stacks)Index
- Whole sheet120
- Basics: images & containers11
- Volumes & networks4
- Find & inspect containers7
- Environment variables & container config12
- Software versions inside containers & images9
- Logs & shells5
- Run containers3
- Images4
- Cleanup6
- Docker Compose v27
- Container lifecycle & live changes10
- Builds, multi-platform & moving images11
- Volumes, networks & remote hosts in depth12
- Compose: more commands9
- Swarm mode10
Swarm mode (services & stacks)10
docker swarm init --advertise-addr <ip>Turn this host into a swarm managerWhat each part does
docker swarm initcreate a single-node swarm with this host as manager--advertise-addr <ip>the address other nodes use to reach it
docker swarm join-token workerGet the join command for workersWhat each part does
join-token workerprint the docker swarm join command (use manager for extra managers)
docker node lsList nodesWhat each part does
docker node lsnodes, status, availability and manager status
docker service create --name <service> --replicas 3 -p 80:80 <image>:<tag>Create a replicated serviceWhat each part does
docker service createa long-running service the swarm keeps alive--replicas 33 tasks spread over the nodes-p 80:80publish through the routing mesh on every node
docker service ls; docker service ps <service>List services and where their tasks runWhat each part does
docker service lsservices with replicas running/desireddocker service ps <service>each task, its node, state and errors
docker service scale <service>=5Scale a serviceWhat each part does
scale <service>=5set the number of replicas
docker service update --image <image>:<new-tag> <service>; docker service rollback <service>Rolling update to a new image, and roll backWhat each part does
service update --imagerolling replace of tasks with the new imageservice rollbackgo back to the previous spec
docker service logs -f <service>Logs of all tasks of a serviceWhat each part does
docker service logsaggregated logs from every task-ffollow
docker stack deploy -c compose.yaml <stack>; docker stack rm <stack>Deploy and remove a stack from a compose fileCautionWhat each part does
stack deploy -c compose.yaml <stack>create or update all services in the filestack rm <stack>remove the stack's services and networks
printf '%s' "$VALUE" | docker secret create <name> -Store a secret for servicesWhat each part does
printf '%s' "$VALUE"the secret value without a trailing newlinedocker secret create <name> -store it encrypted in the swarm; services mount it at /run/secrets/<name>
Nothing matches.
My DevOps Playbook by Angelo John Calleja