mjl.
← All articles

Podman Networks and Container Connectivity

podmancontainersnetworkingdns

Podman networks provide a private communication space for containers. Read IPv4 Subnets, Netmasks, and CIDR before choosing a custom subnet.

Create and inspect a network

podman network create --subnet 10.89.0.0/24 lab-net
podman network inspect lab-net

Do not choose a subnet that overlaps the host, VPN, LAN, or another container network. The default network is not a stable contract for an application; create an application-specific network instead.

Connect services by name

podman run --name backend --detach --network lab-net alpine:3.20 sleep infinity
podman run --name client --rm --network lab-net alpine:3.20 getent hosts backend

The name backend is more useful than the current IP. Container addresses can change when containers are recreated.

Attach an existing container when necessary:

podman network connect lab-net existing-container
podman inspect existing-container

Troubleshoot

podman ps
podman network inspect lab-net
podman exec backend ip addr
podman exec client getent hosts backend

Minimal images may not include ping, ip, or curl. Install diagnostic tools temporarily or test the actual application protocol. A successful DNS lookup does not prove that the service is listening or permitted by a firewall.

Cleanup

podman stop backend
podman rm backend
podman network rm lab-net

This network model is reused by the WordPress and Kubernetes examples.