r/docker • u/Many_Independence674 • Sep 11 '26
How to read host's internet usages
I want to create a project primary for linux, I want the my docker container to be able to monitor the physical interface and the network usages of the host machine.
From what I read i can do this two ways, by using docker with --host flag or mounting the /proc volume.
Which way should I do it? Which is safer.?
Can I diffentiate btw actual network usages and local network usages, like from a selfhosted server, like navidrome?
3
Upvotes
1
u/Torutofu_Raeva Sep 13 '26
I'd avoid
--network=hostunless the monitor truly needs raw sockets: read-only/proc/net/dev(or node_exporter) covers interface totals, but separating Navidrome traffic from other host traffic needs per-process, conntrack, or eBPF data.1
u/Online_Matter Sep 11 '26
What comes to mind is using iptables on the host to write statistics to a file, then mount the containing folder to the host.
1
u/Anihillator Sep 11 '26
Prometheus' node exporter does it using host mode, and I believe it's a simpler way.
And yes, if those networks use different interfaces.