Reputation: 585
I'd like to be able to ping a docker hostname from another docker container. how can i do that ? My containers are on the same docker network.
Can someone guide me where should I look or search, I'm very newbie in networking and do not know about what should i search to fix this problem.
Upvotes: 0
Views: 879
Reputation: 719
The link
option is deprecated so I suggest you to use the --network-alias
option in addition to the --name
flag (see the documentation here and here for more info).
For example, admiting you have a network called test, you can run these two commands (in two separate terminal)
docker run -it --rm --name debian1 --network=test --network-alias=debian1 debian:jessie /bin/bash
docker run -it --rm --name debian2 --network=test --network-alias=debian2 debian:jessie /bin/bash
Then you will be able to ping containers according to their network-alias
Upvotes: 1