Search code examples
dockerdocker-swarm

docker swarm: difference between Replicated and Global services


Based on this picture in this document https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/:

enter image description here

How should the output of the command #docker service ls look like for the two services depicted? My understanding is:

grey                   global              "1/1"                 consul:latest 
yellow                 replicated          "1/3"                  consul:latest

I am not sure about the numbers between "" I need support to understand the output

Correct output based on answer and the picture would be:

 grey                   global              "5/5"                 consul:latest 
 yellow                 replicated          "3/3"                 consul:latest

Solution

  • Without placement constraint, a service in global mode will be deployed with one replica on each cluster node. As a result you will have 5/5 replicas.

    You can use placement constraints to restrict deployment to specific nodes, for instance to worker nodes or nodes having a specific node label:

    • You could use a placement constraint to restrict deployment to your worker nodes, which will result in 4 replicas.

    • You could add a node label to n of your nodes and use it as placement constraint, resulting in n replicas.

    While global mode services guaranty that exactly one replica of a service is running on each node that fulfills the placement constraints, the same is not necessarily true for replicate mode services. Replicated mode services are usually fanned out across the nodes, but could also be placed on a single node...

    Why do you list the replicas to 1/3 for the (yellow) replicated mode service? If all replicas are deployed successfully it should be 3/3.

    The numbers indicates a summary of the total deployment for the service. It does not indicate how the replicas are spread across the cluster, nor where the replicas are running.