Docker Placement in Swarm

# Add labels & contraints on worker node
docker node update --label-add type=cpu-optimized worker1
docker node update --label-add type=memory-optimized worker2
docker node update --label-add type=gp worker3

docker service create --constraint=node.labels.type==cpu-optimized batch-processing
docker service create --constraint=node.labels.type==memory-optimized realtime-analytics
docker service create --constraint=node.labels.type==gp web-servers

#Negate constraint
docker service create --constraint=node.labels.type!=memory-optimized web-servers

# Ensure run only on worker node
docker service create --constraint=node.role==worker web-servers
  •  
  •  
  •  
  •  

Viet Luu has written 276 articles

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

We are thankful for your never ending support.