In my previous blog Docker Swarm – Beginning I’ve started a service called “web” in global mode which runs a single instance of container on all nodes in the swarm. Now lets try to stop container/node and check the behavior.
Stop container – As you can see in the below screenshot stopping a container quickly started one more instance of container on the same node.
Stop node – I’ve stopped one of the node but there is no scale up/down of containers – single container on each of existing nodes.
Start node – So I’ve started the node again and it is immediately joined back the swarm.
And as expected container started on the node..
Now lets remove it and start service in replica mode ( three replicas ) which started containers on all three nodes.
Stop container – Just as in global mode stopping a container on node immediately starting on the same node.
Stop node – I’ve stopped one of the nodes and immediately docker started one more container on worker node2 so two in total running on the same node.
On worker node 2
Start node – I’ve started the node again and it is immediately joined back the swarm but unlike global mode as three containers already running ( 2 on worker node2 and one on manager node ) nothing started on worker node 1.
Now on worker node 2 – I’ve stopped one of the running containers and now docker started it on worker node 1.