4

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

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

vagrant@master:~$ docker node ls
ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
127fuzxjq2j3ashcteu8fo248    worker1   Ready   Active        
43l953k75lv14uw7ni2hbib5j *  master    Ready   Active        Leader

I can use this swarm to successfully run services. But is it possible to obtain 172.28.128.0/16 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.

030
  • 5,731
  • 12
  • 61
  • 107
rsjethani
  • 169
  • 1
  • 1
  • 5
  • Have you tried `docker inspect --format '{{ .NetworkSettings.IPAddress }}' $container_id`? – dawud Jan 09 '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 08: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

1 Answers1

6
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

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

and

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

returns the IP address.

030
  • 5,731
  • 12
  • 61
  • 107