Docker Swarm Guide
Docker Swarm turns a pool of Docker hosts into a single virtual host. You deploy services (with replicas) and the swarm schedules them across nodes. See official Swarm docs.
Last updated: April 2026
Check if Swarm is active
Swarm is part of Docker Engine. Check whether the current node is in swarm mode.
docker info | grep -i swarmInitialize a swarm (manager node)
Run on the machine that will be the manager. Only run once per cluster.
docker swarm initDeploy a stack
Save your compose file (e.g. stack.yml) and deploy. Use pre-built images (no build: in Swarm unless you build on each node).
docker stack deploy -c stack.yml mystackUseful Swarm commands
docker service lsdocker node lsdocker service scale mystack_web=3docker stack rm mystackSample stack file
Compose file suitable for docker stack deploy. Uses image only (no build).
services:
web:
image: nginx:alpine
deploy:
replicas: 2
restart_policy:
condition: on-failure
ports:
- "80:80"
SwarmBot
AI-powered assistant