1

I have a 3 node docker swarm cluster and I am trying to get the IPs of each one via docker node inspect node-1 --format '{{ .Status.Addr }}' but I am having an issue where when the node I am trying for (example node-1 from above), that I get back 0.0.0.0. This only happens on the leader node, the others work just fine.

What is happening in this case? Also, how can I use docker commands to get the IP of all the nodes when checking with their hostnames or docker node ls?

1

I ended up using {{.ManagerStatus.Addr}} and stripping the port number from the results with sed.

for NODE in $(docker  node ls -f 'role=manager' --format '{{.Hostname}}'); do
  docker node inspect --format '{{.ManagerStatus.Addr}}' ${NODE} | sed 's/:2377//'
done
0

Related bug that i have found

Status.Addr uses the gRPC library to determine the address of a given node as viewed by the manager. This means, for example, if a worker node was behind a proxy, it would give the proxy's address as Status.Addr, even if the worker itself didn't "know" it was behind a proxy.

For ManagerStatus.Addr, the address given is the advertise address of the manager, as may have been set with --advertise-addr when doing init or join. The advertise address must be correct, because that's the address that the other managers know to connect to this manager at.

https://github.com/moby/moby/issues/35437

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy