I have a container that needs access to the host OS’s /proc filesystem. So I’m mounting it in my docker-compose file as /host/proc
nodeexporter:
image: prom/node-exporter:v0.18.1
container_name: nodeexporter
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
This works fine when I’m running the container in host network mode:
$ docker exec -it nodeexporter cat /host/proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
veth881bc02: 8210554 50692 0 0 0 0 0 0 112567920 54332 0 1 0 0 0 0
wlan0: 4286020079 574432486 0 0 0 0 0 1472409 3629829823 850309400 0 0 0 0 0 0
eth0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[...]
So I can see the network interfaces on the host OS.
I’d prefer to run that container in bridge mode. However, when I do that, it no longer mounts the host proc filesystem:
$ docker exec -it nodeexporter cat /host/proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
eth0: 106593 1117 0 2 0 0 0 0 1553940 928 0 0 0 0 0 0
Here I’m actually get the statistics of the network interfaces inside the container. So /home/proc is mounting the container’s /proc, rather than the host’s /proc.
Anything I can do to avoid this?
Running 19.03.5 docker in the latest version of Raspian.