I have two virtualbox ubuntu16 guests which can communicate over a host-only network:

I created a docker swarm using the steps from docker docs. Following is the state of my swarm:

vagrant@master:~$ docker node ls
127fuzxjq2j3ashcteu8fo248    worker1   Ready   Active        
43l953k75lv14uw7ni2hbib5j *  master    Ready   Active        Leader

I can use this swarm to successfully run services. But is it possible to obtain based IP address of the nodes via docker? I tried looking at docker commandline reference as well as docker remote api . My objective is to contact any swarm node via remote api but for that I would require its underlying api on which remote docker daemon is enable for listening.

  • Have you tried docker inspect --format '{{ .NetworkSettings.IPAddress }}' $container_id? – dawud Jan 9 '17 at 15:03
  • @dawud This gives me docker0(172.17.*) interface related IP but not the public IP(172.28.128.*) of the host – rsjethani Jan 25 '17 at 8:50
  • Try checking the full output of docker inspect $container_id, check if any of the items listed contains the information you need. That was just an example/hint. – dawud Jan 25 '17 at 13:32
ubuntu@ubuntu-xenial:~$ docker node inspect -h
Flag shorthand -h has been deprecated, please use --help

Usage:  docker node inspect [OPTIONS] self|NODE [NODE...]

Display detailed information on one or more nodes

  -f, --format string   Format the output using the given Go template
      --help            Print usage
      --pretty          Print the information in a human friendly format


ubuntu@ubuntu-xenial:~$ docker node inspect self --format '{{ .Status.Addr  }}'

returns the IP address.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.