10.8. Communicating between containers using DNS
When a DNS plugin is enabled, use a container name to address containers.
Prerequisites
-
The
container-toolsmeta-package is installed. -
A network with the enabled DNS plugin has been created by using the
podman network createcommand.
Procedure
Run a
receivercontainer attached to themynetnetwork:# podman run -d --net mynet --name receiver ubi10 sleep 3000Run a
sendercontainer and reach thereceivercontainer by its name:# podman run -it --rm --net mynet --name sender alpine ping receiver PING rcv01 (10.89.0.2): 56 data bytes 64 bytes from 10.89.0.2: seq=0 ttl=42 time=0.041 ms 64 bytes from 10.89.0.2: seq=1 ttl=42 time=0.125 ms 64 bytes from 10.89.0.2: seq=2 ttl=42 time=0.109 msExit using the
CTRL+C.You can see that the
sendercontainer can ping thereceivercontainer using its name.