简体   繁体   中英

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.

Docker provides two types of network solutions for multi-host networking 1) Overlay network with/without docker swarm 2) Macvlan network. I would like to know for the 2nd type Macvlan networks how can i achieve the objective

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 .

Then you can try to ping another service. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM