Docker Community Forums

Share and learn in the Docker community.

Docker service not respecting placement-pref upon restart

docker

(Oyshikmoitra) #1

Hi,

I have a docker swarm which has 10 nodes. Out of these I have labeled 4 nodes (via docker node update --label-add mylabel [nodes1....4] ). After this I create a service as follows:

docker service create --name myservice \
--network my-net \
--constraint  'node.labels.type == mylabel' \
--placement-pref 'spread=node.description.hostname' \
--replicas=12 \
myImage:v1.0

Now since all my nodes have distinct hostname, I expect the service to distributed across all the 4 node evenly (i.e. 3 replicas each node with label “mylabel”). Till now the behavior is as expected.

Now, I have to shutdown the nodes at the end of the day. Then next day when I start the nodes again I expect the replicas to be still evenly distributed but it is not. Now the service gets randomly distributed (sometimes , all the replicas end up in the same node).

I need to control this behavior, so that when the nodes are switched backup the replicas are evenly distributed. Is this possible? If yes then how?

General Info:
OS: Ubuntu 16.04.3 LTS
docker version : 17.09.0-ce

Thank, Oyshik


(Oyshikmoitra) #2

Still stuck with this issue. Anyone???