Each container is associated to a virtual Ethernet interface on the host named like veth7K7R1J
. I can find it in /sys/class/net/veth7K7R1J/statistics
. But I'm wondering how to find this relationship. Is there a way to do this?
Given eth0
inside the container, you need to find the peer_ifindex (which you can do with ethtool -S
) and then identify that interface index on the host (with ip link
). So:
$ docker run -it --rm ubuntu:14.04.2 bash
root@07e330775e98:/# apt-get update && apt-get install -y ethtool
[...]
root@07e330775e98:/# ethtool -S eth0
NIC statistics:
peer_ifindex: 875
Then on the host again:
$ ip link | grep '^875:'
875: vethdd8c173: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With