How to fix this issue "no suitable node (scheduling constraints not satisfied on 1 node)" in docker swarm while deploying registry?

Arul Ranjith picture Arul Ranjith · May 24, 2017 · Viewed 17.4k times · Source

I have a docker swarm in a virtual machine with 2 core 4GB ram Centos.

In the swarm when I deploy docker private registry (registry 2.6.4) it shows service status as pending forever. I used docker service ps <<registry_name>>

And when i inspect using docker inspect <<task_id>> in message I got this "no suitable node (scheduling constraints not satisfied on 1 node)".

I tried service restart and redeployment.

How to fix this?

Answer

Jo&#227;o Matos picture João Matos · Dec 11, 2017

I often run into this problem when there is a mismatch between the node labels defined in the compose file and the ones defined in the actual node, either because I set a wrong label (e.g. a typo) or simply forgot to label nodes at all.

To label nodes:

1) For each target node do:

docker-machine ssh <manager_node_name> 'docker node update --label-add <label_name>=<label_value> <target_node_name>'

2) Make sure they match the ones defined in the compose file.

3) restart docker service in manager node

for example:

compose file:

 dummycontainer:
    image: group/dummyimage
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.labels.dummy_label == dummy]
      restart_policy:
        condition: on-failure

assuming that I want to deploy this replica in a node called dummy_node:

docker-machine ssh manager_node 'docker node update --label-add dummy_label=dummy dummy_node'

and restart docker in the manager node.

Finally, if you deploy you should expect dummycontainer running in dummy_node, assuming that the label was correctly set in both steps. Otherwise it is expectable to see the error you are getting.

Best regards