I have a swarm cluster built from 8 nodes with node.role set on the engine level.
I need to create a service with several replicas that can run on 2 nodes (out of 8).
What would be the right syntax to do it?
I tried:
–constraint ‘engine.labels.role in (master, worker)’
–constraint 'engine.labels.role==/master|worker/'
it didn’t work…
Did you find an answer eventually?
I was also looking for a solution. My current solution is to add a constraint after launching the services.
docker service create --constraint 'node.role==worker' --name redis redis
docker service update --constraint-add 'engine.labels.purpose==database' redis
You could actually specify the node labels before running a service with docker node update --label-add
from a manager node.