Reputation: 433
I am new to docker and hence I have this naive doubt in my mind. I want a way that whenever I create a service, it gets created on a specific node but if I scale it, it should get scaled to other nodes too present in docker swarm. I know about --mode global and --constraints node.hostname!=node-1. But that does not solve my problem. Let me if my question is unclear, I will try to explain it in a better way.
Upvotes: 1
Views: 3448
Reputation: 146630
You need to use placement-pref and have two groups, one for the node where you want to run it and then for other nodes in another group.
$ docker service create \
--replicas 1 \
--name myservice \
--placement-pref 'spread=node.labels.main_machine' \
--placement-pref 'spread=node.labels.extended_machines' \
<yourimage>
Now your first one would go on main_machine
and the scaled ones would go to extended_machines
Upvotes: 6