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

How do I list Docker VIP addresses?

· 52CE 我爱测

I can list all container IP address inside a docker overlay network using: ~# docker network inspect <network_id> I'm trying to do resolver troubleshooting in some Docker swarm stack. It seems that resolving is done to the wrong …

问题原文

原帖链接 · Tim · CC BY-SA 4.0

I can list all container IP address inside a docker overlay network using:

~# docker network inspect <network_id>

I'm trying to do resolver troubleshooting in some Docker swarm stack. It seems that resolving is done to the wrong IP address, but I want to check if it is resolved to a VIP first. I'm talking the network between containers, not the ingress network.

In my quest I found this Docker Issue comment. Which suggests this:

From a debugging point of view, the tool to use are:

  1. tcpdump
  2. ipvsadm --> load balancer is done with ipvs

But I'm unable to find which ipvsadm options to use to print the VIP's used inside my docker network.

已采纳解答

原帖链接 · BMitch · CC BY-SA 4.0

You can lookup the VIP for a service with an inspect on the service itself (I typically use jq to format the json output):

docker service inspect --format '{{json .Endpoint.VirtualIPs}}' ${service_name} \
 | jq .

To loop over all your services, you can do a little scripting:

for service in $(docker service ls -q); do
  docker service inspect --format \
     '{{.Spec.Name}}: {{range .Endpoint.VirtualIPs}}{{.Addr}} {{end}}' \
     ${service}
done

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

资料来源与适用范围

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

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

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