Configuring Container Networking with Podman

Last Updated : 23 Jul, 2025

Podman is a lightweight program to run and manage Open Container Initiative-compliant containers. Depending on whether the container is rootless or rootful, Podman uses two different networking stacks. Running as rootfull, Podman uses the heavy project container networking plugins.

What is Podman Container Networking?

Podman container networking is managed in several ways Podman controls communication and network connectivity for containers and it's under control with the network command. Netavark and CNI are the two network backends that Podman supports. Podman's new version introduced Netavark as the default network backend. In favor of Netavark, CNI is deprecated and will be eliminated in the upcoming major Podman version 5.0. Use the network_backend key under Network in containers. conf(5) to set the network backend. By default, new systems use network run podman info --format {{.Host.NetworkBackend}} to see which backend is being used.

Step-By-Step Guide to Configuring Container Networking with Podman

Here is the step-by-step implementation of configuring container networking with Podman:

Step 1: Install Podman

First, you need to make sure your system has Podman installed. It is installable via a package manager on a Linux system.

sudo apt-get install podman -y

Output:

Install Podman

Step 2: Create a Custom Network

Next, you can create a unique bridge network to isolate container settings.

podman network create mynetwork

Output:

Create a Custom Network

Step 3: Run a Container in Default Network Mode

Podman operates containers in bridge mode by default so it must have the Default Network Mode.

podman run -d --name mycontainer httpd

Output:

Run a Container in Default Network Mode

Step 4: Expose Ports to the Host

Then, This program launches a container that runs the nginx web server and exposes ports from the container to the host using Podman. Port 80 within the container is mapped to port 8080 on the host by using the -p parameter.

podman run -d -p 8080:80 nginx

Output:

 Expose Ports to the Host

Step 5: Use Rootless Mode Networking

Podman employs user-mode networking via slirp4netns by default when operating in rootless mode.

podman run -d --name rootlesscontainer nginx

Output:

Use Rootless Mode Networking

Step 6: Inspect Networks

In the next step, To see information on a certain network follow the below command.

podman network inspect mynetwork

Output:

 Inspect Networks

Step 7: Manage DNS within Containers

Lastly, Within the same network, podman enables DNS name resolution for containers. As an example, you can use its name to ping another container.

podman exec -it mycontainer ping mycustomcontainer

Output:

Manage DNS within Containers

Best Practices of Container Networking with Podman

  • Isolate Network Traffic: By separating traffic between containers, you may improve security and stop unwanted access. To manage traffic between containers and external networks, set up your host's firewall or use Podman's built-in firewall features.
  • Secure Network Traffic: Inter-container network traffic encryption shields against man-in-the-middle and eavesdropping attacks. When transferring sensitive data across containers, especially over public or untrusted networks, use TLS/SSL.
  • Implement Service Discovery: Service discovery makes container orchestration and scalability easier by enabling communication between containers via service names rather than IP addresses.
  • Leverage Custom Networks: Enabling safe and isolated settings, custom networks provide greater control over container-to-container communication.

Conclusion

In this article, we have learned about configuring container networking with Podman. Configuring container networking with Podman creates a flexible and secure environment for controlling containerized workloads. Using Podman's rootless mode, custom networks, and complex network configurations, you can keep your containers isolated, safe, and efficient.

Comment