buildah only seems to initialize the CNI plugin when buildah from is used, not buildah run. This means that, if you start a build container with no networking (--network=none), trying to add it during the run command fails. The documentation in cni-examples implies that buildah run should configure networking:
When buildah's buildah run command is used, or when buildah build needs to handle a RUN instruction, the processes which buildah starts are run in their own network namespace unless the --network=host option is used.
Steps to reproduce the issue:
Create a build with networking disabled
Run a step with --network=private
Describe the results you received:
Running a build using the default settings yields a correctly-configured network interface:
$ buildah from fedora
fedora-working-container
$ buildah run fedora-working-container dnf install -y -q iproute
Installed:
iproute-5.10.0-2.fc34.x86_64 iproute-tc-5.10.0-2.fc34.x86_64 iptables-libs-1.8.7-8.fc34.x86_64
libibverbs-37.0-1.fc34.x86_64 libmnl-1.0.4-13.fc34.x86_64 libnetfilter_conntrack-1.0.8-2.fc34.x86_64
libnfnetlink-1.0.1-19.fc34.x86_64 libnl3-3.5.0-6.fc34.x86_64 libpcap-14:1.10.1-1.fc34.x86_64
linux-atm-libs-2.5.1-28.fc34.x86_64 psmisc-23.4-1.fc34.x86_64
$ buildah run fedora-working-container ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: tap0: <BROADCAST,UP,LOWER_UP> mtu 65520 qdisc pfifo_fast state UNKNOWN group default qlen 1000
link/ether da:c8:6c:0b:3e:b3 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.100/24 brd 10.0.2.255 scope global tap0
valid_lft forever preferred_lft forever
inet6 fe80::d8c8:6cff:fe0b:3eb3/64 scope link tentative
valid_lft forever preferred_lft forever
However, starting a build with --network=none and then adding --network=private in the run step yields different behavior (note that I have to install the iproute package with the host network namespace):
$ buildah from --network=none fedora
fedora-working-container
$ buildah run --network=host fedora-working-container dnf install -y -q iproute
Installed:
iproute-5.10.0-2.fc34.x86_64 iproute-tc-5.10.0-2.fc34.x86_64 iptables-libs-1.8.7-8.fc34.x86_64
libibverbs-37.0-1.fc34.x86_64 libmnl-1.0.4-13.fc34.x86_64 libnetfilter_conntrack-1.0.8-2.fc34.x86_64
libnfnetlink-1.0.1-19.fc34.x86_64 libnl3-3.5.0-6.fc34.x86_64 libpcap-14:1.10.1-1.fc34.x86_64
linux-atm-libs-2.5.1-28.fc34.x86_64 psmisc-23.4-1.fc34.x86_64
$ buildah run --network=private fedora-working-container ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
Describe the results you expected:
I expected the behavior of running buildah from --network=private fedora and buildah from --network=none fedora followed by buildah run --network=private fedora-working-container to be the same; that buildah-run initializes networking.
Description
buildah only seems to initialize the CNI plugin when
buildah from
is used, notbuildah run
. This means that, if you start a build container with no networking (--network=none
), trying to add it during therun
command fails. The documentation in cni-examples implies thatbuildah run
should configure networking:Steps to reproduce the issue:
Describe the results you received:
Running a build using the default settings yields a correctly-configured network interface:
However, starting a build with
--network=none
and then adding--network=private
in the run step yields different behavior (note that I have to install the iproute package with the host network namespace):Describe the results you expected:
I expected the behavior of running
buildah from --network=private fedora
andbuildah from --network=none fedora
followed bybuildah run --network=private fedora-working-container
to be the same; that buildah-run initializes networking.Output of
rpm -q buildah
orapt list buildah
:Output of
buildah version
:Output of
podman version
if reporting apodman build
issue:n/a
*Output of `cat /etc/release`:**
Output of
uname -a
:Output of
cat /etc/containers/storage.conf
: