Hi there,
I would like to be able to communicate between two containers on the same podman network by simply using their hostname or container name, but it doesn’t work. Communication via ip address works as expected.
The two containers are rootful and I have installed the package “cni-plugin-dnsname”.
If i run the following:
someuser@raspi:~> sudo podman network create testdns
testdns
someuser@raspi:~> sudo podman network inspect testdns
[
{
"name": "testdns",
"id": "e7797df9d520f89bf0aa76aef3a0482b5bb7f40d8d1490f3556d66db5da1d517",
"driver": "bridge",
"network_interface": "cni-podman3",
"created": "2023-01-04T22:54:41.867722102+01:00",
"subnets": [
{
"subnet": "10.89.1.0/24",
"gateway": "10.89.1.1"
}
],
"ipv6_enabled": false,
"internal": false,
"dns_enabled": true,
"ipam_options": {
"driver": "host-local"
}
}
]
someuser@raspi:~> sudo podman run -dt --rm --name nginx1 -h nginx1 --network testdns nginx:alpine
6a3a019cc2625446beac7f9048b253c158012ae619c951f914a30be361bedcbf
someuser@raspi:~> sudo podman inspect nginx1 -f '{{ .NetworkSettings.Networks.testdns.IPAddress }}'
10.89.1.6
someuser@raspi:~> sudo podman run -it --rm --name nginx2 -h nginx2 --network testdns nginx:alpine /bin/sh
/ # ping 10.89.1.6
PING 10.89.1.6 (10.89.1.6): 56 data bytes
64 bytes from 10.89.1.6: seq=0 ttl=42 time=0.534 ms
64 bytes from 10.89.1.6: seq=1 ttl=42 time=0.365 ms
64 bytes from 10.89.1.6: seq=2 ttl=42 time=0.362 ms
^C
--- 10.89.1.6 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.362/0.420/0.534 ms
/ # ping nginx1
ping: bad address 'nginx1'
/ # ping nginx2
PING nginx2 (10.89.1.8): 56 data bytes
64 bytes from 10.89.1.8: seq=0 ttl=42 time=0.197 ms
64 bytes from 10.89.1.8: seq=1 ttl=42 time=0.240 ms
64 bytes from 10.89.1.8: seq=2 ttl=42 time=0.239 ms
^C
--- nginx2 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.197/0.225/0.240 ms
/ #
It seems I can issue a ping command using the IP address but not the hostname…
What could be wrong there?
This is a slightly shortened output:
someuser@raspi:~> sudo podman info
host:
arch: arm64
distribution:
distribution: '"opensuse-microos"'
version: "20221219"
kernel: 6.0.12-1-default
networkBackend: cni
os: linux
security:
rootless: false
plugins:
authorization: null
log:
- k8s-file
- none
- passthrough
- journald
network:
- bridge
- macvlan
- ipvlan
volume:
- local
registries:
search:
- registry.opensuse.org
- docker.io
version:
Version: 4.3.1