1

I'm using podman v3.0.2 and trying to change the subnet of an existing podman network. I searched the podman and CNI documentations, but I could not find the way. Is there any correct way to change the network of an existing podman network?

Background

I already created some containers with podman default network (subnet: 10.88.0.1/16) and want to use the subnet of it for others. I think the simplest way is changing the subnet of it and want to know it.

The way I tried

I managed to change it by the following procedures, but it does not seem officially documented. Also, I think the OS reboot is redundant and want to avoid it.

  1. Stop the all containers connecting to the network.
  2. Change subnet section in the CNI network file.
  3. Reboot OS
  4. Start the containers stopped in the procedure1.

I used this way referred from the changing the DNS in the CNI network file in the podman documentation. https://podman.io/getting-started/network#using-dns-in-container-networks

user2738844
  • 169
  • 3
  • 10

2 Answers2

0

This question is a bit stale, but maybe other folks will find this answer useful. What caught my eye was:

  1. Reboot OS

You shouldn't need to reboot your OS.

The following procedure works for me:

  1. Shut down all the containers on the network.
  2. Remove the bridge device by running ip link del cni-podman0 (or whatever bridge name is configured for that network)
  3. Edit the CNI file in /etc/cni/net.d
  4. Start the containers you started in step 1.

The above steps are all performed as root.

larsks
  • 277,717
  • 41
  • 399
  • 399
0

Default network:

In RHEL 9, the default configuration is derived from /usr/share/containers/containers.conf. You can copy this file to /etc/containers/containers.conf and set the default_network variable if you would like to use a different subnet for the default network. You can then apply the config with systemctl restart podman

Manually added network:

If you created a network with podman network create test-net then the config will be in /etc/containers/networks/test-net.json by default, but could be in /etc/cni if you have configured the cni backend in containers.conf.

See /usr/share/man/man1/podman-network-* for more info

ThankYee
  • 101
  • 3