[英]How can i ping a local docker container from an outside host using macvlan network?
objective : assume two hosts A & B. container x at A should be able to be pinged from host B such that this container x is present in the same network as A & B and has its own ip address. 目标:假设有两个主机A和B。位于A的容器x应该能够从主机B进行ping操作,以使该容器x与A&B位于同一网络中并具有自己的IP地址。
Docker provides two types of network solutions for multi-host networking 1) Overlay network with/without docker swarm 2) Macvlan network. Docker为多主机网络提供了两种类型的网络解决方案:1)有/没有docker swarm的覆盖网络2)Macvlan网络。 I would like to know for the 2nd type Macvlan networks how can i achieve the objective 我想知道第二种Macvlan网络如何实现目标
When services are running, you can attache them for debugging with 服务运行时,可以将其附加以使用以下命令进行调试
docker exec -ti some-service.1.lz3j7mqb1ux4jp5cwe87gpiok sh
you need to figure out the service name with docker ps
. 您需要使用docker ps
找出服务名称。
Then you can try to ping another service. 然后,您可以尝试ping其他服务。 But this will only work when both services are attached to the same overlay network which is not ingress. 但这仅在两个服务都连接到同一个非入口的覆盖网络时才起作用。
docker network create -d overlay dev
docker service create --network dev --name a ...
docker service create --network dev --name b ...
Then you can ping a
from b and ping b
from a. 然后你就可以ping a
从B和ping b
从。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.