问题
How can I access the host ARP records from within a Docker container?
I tried to mount a volume (in a docker-compose file) /proc/net/arp:/proc/net/arp
but found out that I can't make any volume with /proc
. Then I tried to mount it elsewhere like /proc/net/arp:/root/arp
, but then if I cat /root/arp
, from within the container, the table comes out empty.
docker run -v /proc/net/arp:/root/arp alpine cat /root/arp <-- returns empty table
Ideas?
回答1:
You should be good if you add privileged mode and make sure you're in host networking mode. This worked for me:
>$ docker run --net host --privileged -v /proc/net/arp:/host/arp alpine cat /host/arp
来源:https://stackoverflow.com/questions/58141091/acessing-arp-table-of-host-from-docker-container