Skip to content
Latchkey

podman network: Container Networking in CI

podman network creates user-defined networks so containers can resolve and reach each other by name.

A test app and its database need to find each other. A shared user-defined network gives them DNS by container name, the same model as docker network.

What it does

podman network creates, lists, inspects, and removes networks. Containers on the same user-defined network resolve each other by name through the built-in DNS (aardvark-dns). Rootless networking uses pasta or slirp4netns for outbound connectivity.

Common usage

Terminal
podman network create appnet
podman run -d --name db --network appnet docker.io/library/postgres:16
podman run --rm --network appnet docker.io/library/postgres:16 \
  psql -h db -U postgres -c 'SELECT 1'
podman network ls
podman network rm appnet

Options

Command/FlagWhat it does
create <name>Create a user-defined network
lsList networks
inspect <name>Show network configuration
connect / disconnectAttach or detach a container
rm <name>Remove a network
--network <name>Run a container on a specific network

In CI

Put cooperating containers on one podman network create so they reach each other by name, rather than relying on host ports. Name-based DNS only works on user-defined networks, not the default one, so always create a network for multi-container tests.

Common errors in CI

A container that cannot resolve a peer by name is usually on the default network where DNS is off; create a user-defined network and attach both. "could not find pasta ... slirp4netns" in rootless mode means neither rootless network helper is installed; install pasta or slirp4netns. "network ... is being used by container" on rm means a container is still attached; disconnect or remove it first.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →