Chapter 10. Managing a container network


Manage container networking to control communication between containers and external systems. With Podman, you can create, inspect, and manage networks to isolate traffic and help maintain security.

10.1. Listing container networks

To display the network names, drivers, and other configuration details for both root and rootless environments, view available container networks.

Podman works with two network behaviors - rootless and rootful: * Rootless networking - the network is set up automatically, the container does not have an IP address. * Rootful networking - the container has an IP address.

Prerequisites

  • The container-tools meta-package is installed.

Procedure

  • List all networks as a root user:

    # podman network ls
    NETWORK ID    NAME        VERSION     PLUGINS
    2f259bab93aa  podman      0.4.0       bridge,portmap,firewall,tuning
    • By default, Podman provides a bridged network.
    • List of networks for a rootless user is the same as for a rootful user.

      For more information, see the podman-network-ls(1) man page on your system.

10.2. Inspecting a network

View detailed configuration of a specific network by using the podman network inspect command. This reveals settings like subnets, gateways, and enabled plugins.

Prerequisites

  • The container-tools meta-package is installed.

Procedure

  • Inspect the default podman network:

    $ podman network inspect podman
    [
        {
            "cniVersion": "0.4.0",
            "name": "podman",
            "plugins": [
                {
                    "bridge": "cni-podman0",
                    "hairpinMode": true,
                    "ipMasq": true,
                    "ipam": {
                        "ranges": [
                            [
                                {
                                    "gateway": "10.88.0.1",
                                    "subnet": "10.88.0.0/16"
                                }
                            ]
                        ],
                        "routes": [
                            {
                                "dst": "0.0.0.0/0"
                            }
                        ],
                        "type": "host-local"
                    },
                    "isGateway": true,
                    "type": "bridge"
                },
                {
                    "capabilities": {
                        "portMappings": true
                    },
                    "type": "portmap"
                },
                {
                    "type": "firewall"
                },
                {
                    "type": "tuning"
                }
            ]
        }
    ]

    You can see the IP range, enabled plugins, type of network, and other network settings.

    For more information, see the podman-network-inspect(1) man page on your system.

10.3. Creating a network

Create custom networks for your containers by using the podman network create command. You can configure external access or create isolated internal networks for secure container communication.

By default, Podman creates an external network. You can create an internal network in which containers can communicate with other containers on the host, but cannot connect to networks outside the host.

Prerequisites

  • The container-tools meta-package is installed.

Procedure

  • Create the external network named mynet:

    # podman network create mynet
    /etc/cni/net.d/mynet.conflist

Verification

  • List all networks:

    # podman network ls
    NETWORK ID    NAME        VERSION     PLUGINS
    2f259bab93aa  podman      0.4.0       bridge,portmap,firewall,tuning
    11c844f95e28  mynet       0.4.0       bridge,portmap,firewall,tuning,dnsname

    You can see the created mynet network and default podman network.

Note

Beginning with Podman 4.0, the DNS plugin is enabled by default if you create a new external network by using the podman network create command.

Refer to podman-network-create(1) man page on your system for more information.

10.4. Connecting a container to a network

To allow the container to communicate on multiple networks simultaneously, you can attach a running container to an additional network by using the podman network connect command.

Prerequisites

  • The container-tools meta-package is installed.
  • A network has been created by using the podman network create command.
  • A container has been created.

Procedure

  • Connect a container named mycontainer to a network named mynet:

    # podman network connect mynet mycontainer

Verification

  • Verify that the mycontainer is connected to the mynet network:

    # podman inspect --format='{{.NetworkSettings.Networks}}' mycontainer
    map[podman:0xc00042ab40 mynet:0xc00042ac60]

    You can see that mycontainer is connected to mynet and podman networks.

10.5. Disconnecting a container from a network

Detach a container from a specific network by using the podman network disconnect command. This stops the container from communicating on that network without stopping the container itself.

Prerequisites

  • The container-tools meta-package is installed.
  • A network has been created by using the podman network create command.
  • A container is connected to a network.

Procedure

  • Disconnect the container named mycontainer from the network named mynet:

    # podman network disconnect mynet mycontainer

Verification

  • Verify that the mycontainer is disconnected from the mynet network:

    # podman inspect --format='{{.NetworkSettings.Networks}}' mycontainer
    map[podman:0xc000537440]

    You can see that mycontainer is disconnected from the mynet network, mycontainer is only connected to the default podman network.

    Refer to podman-network-disconnect(1) man page on your system for more information.

10.6. Removing a network

Delete unused networks by using the podman network rm command. Note that you cannot remove a network if it is currently in use by any containers.

Prerequisites

  • The container-tools meta-package is installed.

Procedure

  1. List all networks:

    # podman network ls
    NETWORK ID    NAME        VERSION     PLUGINS
    2f259bab93aa  podman      0.4.0       bridge,portmap,firewall,tuning
    11c844f95e28  mynet       0.4.0       bridge,portmap,firewall,tuning,dnsname
  2. Remove the mynet network:

    # podman network rm mynet
    mynet
    Note

    If the removed network has associated containers with it, you have to use the podman network rm -f command to delete containers and pods.

Verification

  • Check if mynet network was removed:

    # podman network ls
    NETWORK ID    NAME        VERSION     PLUGINS
    2f259bab93aa  podman      0.4.0       bridge,portmap,firewall,tuning

    For more information, see podman-network-rm(1) man page on your system.

10.7. Removing all unused networks

Use the podman network prune to remove all unused networks. An unused network is a network which has no containers connected to it. The podman network prune command does not remove the default podman network.

Prerequisites

  • The container-tools meta-package is installed.

Procedure

  • Remove all unused networks:

    # podman network prune
    WARNING! This will remove all networks not used by at least one container.
    Are you sure you want to continue? [y/N] y

Verification

  • Verify that all networks were removed:

    # podman network ls
    NETWORK ID    NAME        VERSION     PLUGINS
    2f259bab93aa  podman      0.4.0       bridge,portmap,firewall,tuning

    For more information, see the podman-network-prune(1) man page on your system.

Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top