Swarm mode

docker swarm init turns Docker engines into a cluster: managers keep the desired state and schedule work, workers run it. You describe services; the cluster keeps them running across the nodes.

How it works

Nodes join with a token (docker swarm join). docker node ls lists them with their status (Ready, Down), availability (Active, Pause, Drain) and manager status (Leader, Reachable). docker stack deploy -c stack.yaml name reads a Compose file and creates one service per entry; deploy: is honoured, build: and depends_on: are ignored. Each node still has its own images, containers and volumes.

What breaks

Treating the cluster like one big server: an image built on the manager, a volume created on one node, a file in the manager's folder are all invisible to the other nodes. Draining a node (docker node update --availability drain) moves its tasks away, and shows at once what could not run anywhere else.

In a terminal

docker node ls
docker node update --availability drain manager-1
docker stack deploy -c stack.yaml shop
docker stack ps shop

See it break, then fix it

Write the Dockerfile or the compose file, type the docker commands, and watch a simulated server run them through reboots, upgrades and traffic. Free to start.