How do I list Docker VIP addresses?

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.

1
задан 7 August 2018 в 14:55
1 ответ

Вы можете найти VIP-адрес службы с помощью проверки самой службы (я обычно использую jq для форматирования вывода json):

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

Чтобы перебрать все ваши службы, вы можете написать небольшой сценарий:

for service in $(docker service ls -q); do
  docker service inspect --format \
     '{{.Spec.Name}}: {{range .Endpoint.VirtualIPs}}{{.Addr}} {{end}}' \
     ${service}
done
3
ответ дан 3 December 2019 в 18:27

Теги

Похожие вопросы