docker service create --name worker --replicas 2 --constraint 'node.role==worker' myapp:latest

Category: Docker

docker service create --name worker --replicas 2 --constraint 'node.role==worker' myapp:latest

Create a service constrained to worker nodes

Runs two replicas of myapp only on nodes whose role is worker, keeping managers free of workloads. Constraints are placement rules evaluated per node. Other keys include node.labels and node.hostname.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.