Service Modes

  • Notice it in docker service ls
  • Defaults to replicated, but global is an option
  • Global = one task per node
  • Set on service create only, must remove service to change
  • Good for host agents (security, monitoring, backup, proxy, etc.)
  • 1.13+ Global Mode can be combined with Constraints

Examples

  • Place one task on each node in Swarm
    • docker service create --mode=global nginx
  • Place one task on each Worker in Swarm
    • docker service create --mode=global --constraint=node.role==worker nginx

Hands On

[node1] ~> docker service create --mode=global --name test1 nginx
q8shwxzsucgwi6b6kijfn55nq
overall progress: 3 out of 3 tasks
rru8z0gj9riq: running   [==================================================>]
th2nb6uc5j61: running   [==================================================>]
tsojlv10aqlv: running   [==================================================>]
verify: Service converged

[node1] ~> docker service create --mode=global --name test2 --constraint=node.role==worker nginx
qlzmyl2fmouim1p5rsxj09l7w
overall progress: 2 out of 2 tasks
tsojlv10aqlv: running   [==================================================>]
rru8z0gj9riq: running   [==================================================>]
verify: Service converged

It might be good to run special devops or maintenance services on worker nodes (backup, proxy, monitoring, etc.)

Service Modes in Stack Files

version: "3.1"
services:
  web:
    image: nginx
    deploy:
      mode: global

results matching ""

    No results matching ""