I'm trying to access the host's network interfaces from inside a Docker container with the host-network option.
For debugging purposes I tried to run a clean Alpine
container using docker run --network host --rm -it alpine:3.9
. Running ip link
returns
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: tap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65520 qdisc pfifo_fast state UP qlen 1000
link/ether 62:db:1e:6b:52:fe brd ff:ff:ff:ff:ff:ff
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:9a:e6:96:40 brd ff:ff:ff:ff:ff:ff
I would expect the same result as on my host machine with all the interfaces (lo
, two wired and one wireless interface, docker
). Why is that not the case?
UPDATE to include various outputs:
dpkg -l | grep docker
:
ii docker-ce 5:20.10.12~3-0~raspbian-bullseye armhf Docker: the open-source application container engine
ii docker-ce-cli 5:20.10.12~3-0~raspbian-bullseye armhf Docker CLI: the open-source application container engine
ii docker-ce-rootless-extras 5:20.10.12~3-0~raspbian-bullseye armhf Rootless support for Docker.
tail -4 /proc/cpuinfo
:
Hardware : BCM2711
Revision : d03114
Serial : 1000000025d45b15
Model : Raspberry Pi 4 Model B Rev 1.4
cat /etc/debian_version
:
11.2
Executing the command with sudo
fixes the issue as a workaround.
Executing the run
-command without sudo
after a dockerd-rootless-setuptool.sh
installation causes the stated issue where the network interfaces are not available, instead a virtual interface is created.