简体   繁体   English

我如何使用macvlan网络从外部主机ping本地docker容器?

[英]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.

相关问题 Docker容器无法使用macvlan网络驱动程序访问或ping WAN - Docker container can't reach or ping WAN using macvlan network driver 无法通过Docker桥接容器按名称ping主机网络 - Can't ping host network by name from Docker bridged container 为什么我在使用macvlan时无法通过其主机名从外部计算机ping容器? - Why I can't ping container by its hostname, from an external machine, while using macvlan? 使用Macvlan驱动程序时如何从同一网络上的不同主机访问容器 - How to access container from different host on same network when using macvlan driver docker 主机和容器中的网络设置使用用户定义的桥接网络,其中从主机到容器的 ping 失败 - Network setting in docker host and container using user defined bridge network, where ping fails from host to container 使用 macvlan 的 docker 容器的网络路由 - Network routing for docker container using macvlan 容器内的 Docker Macvlan 网络无法连接到自己的主机 - Docker Macvlan network inside container is not reaching to its own host 如何从主机外部(同一网络)连接到 docker 容器 [Windows] - How to connect to a docker container from outside the host (same network) [Windows] 我怎么能从我的主机 ping 我的 docker 容器 - How could I ping my docker container from my host docker macvlan - 没有到主机的路由(容器) - docker macvlan - no route to host (container)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM