大网数据广告活动
服务器运维问答

How to get IP address of a docker swarm node?

· 52CE 我爱测

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 l…

问题原文

原帖链接 · rsjethani · CC BY-SA 3.0

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 · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-01-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。