Docker – Status: Error response from daemon: node elk12 is ambiguous (2 matches found), Code: 1

dockerdocker-swarm

I'm using following environment: Debian 9 with Docker CE:

# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
# docker --version
Docker version 17.09.0-ce, build afdb6d4
# 

docker node ls:

# docker node ls | grep elk12
2keku0oj8zhsy6uyvyl4gd4d7     elk12               Down                Active              Reachable
tbwbpkl5qys4wwxbisga3y2oe *   elk12               Ready               Active              Reachable
# docker node inspect elk12
[]
Status: Error response from daemon: node elk12 is ambiguous (2 matches found), Code: 1
#

I cannot use docker node rm elk12, as I according to above output I have 2.

How does one proceed to remove "down" node from list, preferably without affecting working cluster). I don't believe I even have that node anymore (probably some leftovers from long time ago) …

Please advise.


UPDATE:

# docker node rm 2keku0oj8zhsy6uyvyl4gd4d7
Error response from daemon: rpc error: code = FailedPrecondition desc = node 2keku0oj8zhsy6uyvyl4gd4d7 is a cluster manager and is a member of the raft cluster. It must be demoted to worker before removal
# docker node demote 2keku0oj8zhsy6uyvyl4gd4d7
Manager 2keku0oj8zhsy6uyvyl4gd4d7 demoted in the swarm.
# docker node rm 2keku0oj8zhsy6uyvyl4gd4d7
2keku0oj8zhsy6uyvyl4gd4d7
# docker node ls | grep elk12
tbwbpkl5qys4wwxbisga3y2oe     elk12               Ready               Active              Reachable
# 

Best Answer

The issue you're having with a duplicated node with the same name but different ID is explained here, probably a node that left the swarm and rejoined it, a manager restart...

If you want to remove the duplicated node and get rid of that ambigous warning, you may use the hash ID and not the name:

docker node rm 2keku0oj8zhsy6uyvyl4gd4d7

If you want to remove the other node named elk12, it seems that the node is a manager so you should proceed with caution as you may run into troubles if there are not enough managers to reach a consensus. If you feel it's safe to remove that manager node because you have enough nodes running as managers in your swarm, you should perform the following:

  1. Demote the manager node (docker node demote). So that node is no longer a manager node and runs as a worker node.
  2. Drain the worker node (docker node drain). The containers running in the elk2 would be moved to other worker nodes in the cluster.
  3. Make the worker node leave the Swarm (docker swarm leave inside the elk2 node)
  4. Remove the node (docker node rm ...)
Related Topic