Marina Cozma
Marina Cozma

Reputation: 3

How can I connect to a docker container using its name instead of its IP address?

How can I connect to a docker container using its name instead of its IP address using the ping command?

ping <container_name> instead of ping <IP_address>

Upvotes: 0

Views: 117

Answers (2)

YYY
YYY

Reputation: 6341

ping $(docker inspect -f {{.NetworkSettings.IPAddress}} <container_name>)

Upvotes: 1

hzitoun
hzitoun

Reputation: 5832

Check Network-scoped alias. It allows you to ping a container by its name.

Upvotes: 2

Related Questions