0

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
5t4cktr4c3
  • 151
  • 1
  • 10
  • If you're running Docker on MacOS or Windows, it runs inside a Linux virtual machine. When running in `--network host` mode you'll see the interfaces of the virtual machine, not of your host. – larsks Feb 07 '22 at 12:02
  • @larsks Running on a Raspberry Pi – 5t4cktr4c3 Feb 07 '22 at 12:03
  • Something is screwy. I wonder if you could update your question to include the output of `dpkg -l | grep docker`, `tail -4 /proc/cpuinfo`, and `cat /etc/debian_version`? – larsks Feb 07 '22 at 12:19
  • I'm at a loss. For comparison, here's the output of the above on my Pi 4: https://gist.github.com/larsks/63e272e8c64a2d439cbd3fdfc790a0fd – larsks Feb 07 '22 at 13:31
  • Any idea what I could possibly do or what could be the issue? I tried reinstalling again. Tried on my Pi 3 and the results are as expected. – 5t4cktr4c3 Feb 07 '22 at 17:22
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/241801/discussion-between-larsks-and-5t4cktr4c3). – larsks Feb 07 '22 at 19:38

1 Answers1

1

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.

5t4cktr4c3
  • 151
  • 1
  • 10