3 ms·
It is very difficult getting containers that aren’t in a pod together to be able to talk to each other, with rootless pods, and without just host-binding everyt
by misnome 4y ago
It is very difficult getting containers that aren’t in a pod together to be able to talk to each other, with rootless pods, and without just host-binding everything. None of the normal hostname conveniences are in place, and if it’s possible to do it isn’t default and probably needed much more underlying knowledge than I had when I tried.
- yrro 4y agoI think the new network implementation in Podman 4 ("netavark") helps with that sort of thing. So the following works: [sam@isis ~]$ podman network create foo foo [sam@isis ~]$ podman run -d --name=host1 --network=foo --init registry.access.redhat.com/ubi9/ubi-minimal sleep inf 1f7ffa0e474f7116d782ffa4d8dd9c0454893e9dac54b2cd9e61481a7f86a2ff [sam@isis ~]$ podman run -d --name=host2 --network=foo --init registry.access.redhat.com/ubi9/ubi-minimal sleep inf d8ffa58cb9de77305545b9f85043c016d03193adb6543b1768a68623b044b0e5 [sam@isis ~]$ podman exec host1 getent ahosts host2 10.89.0.3 STREAM host2.dns.podman 10.89.0.3 DGRAM 10.89.0.3 RAW [sam@isis ~]$ podman exec host2 getent ahosts host1 10.89.0.2 STREAM host1.dns.podman 10.89.0.2 DGRAM 10.89.0.2 RAW i.e., we have a network called 'foo' to which containers 'host1' and 'host2' are attached; they can resolve each others hostnames. It's worth noting if you are trying this on a system where you previously ran podman <= 3, I think you have to 'podman system reset' to get a new configuration with the new Podman 4 network implementation. (Personally I just run all containers with --host=net, this is just for local development, who cares) I think this will work with docker-compose as long as you 'systemctl --user start podman.socket' and 'export DOCKER_HOST=unix:/$XDG_RUNTIME_DIR/podman/podman.sock'.
- kuratkull 4y agoHad the same issue, the containers did not resolve each other by hostname. This fixed it (run on the host): apt install containernetworking-plugins podman-plugins
- yrro 4y agoThat's not needed/used since Podman 4, where the networking stack was rewritten; one of the features of the new "netavark" stack is that it has DNS resolution for containers within a network by default, no plugin needed.