Docker Community Forums

Share and learn in the Docker community.

Relationship between interface "vethxxxxx" and container?

(Snayak12) #22

From host:

cat /sys/class/net/veth45562ed/iflink


ethtool -S veth45562ed

NIC statistics:
peer_ifindex: 767

From Container

6b63d46e1ac7# ethtool -S eth0
NIC statistics:
peer_ifindex: 768
6b63d46e1ac7:/# cat /sys/class/net/eth0/iflink

(Micahculpepper) #23

@khatribharat is correct; however, to be able to cat the files in question, you need cat available inside your container. I’m often working with containers that are simple compiled binaries and don’t have access to normal utilities. In that case, you can still get at the needed information, but it requires a little more work. So I made a script to correlate containers with their veth interfaces:

Example output:

[root@dockervisor-1 ~]# dockerveth
60d27ce962ff	vethe353e93	hopeful_bhaskara
d07a2979e69a	vethe4c3cee	silly_meitner
1e8656e195ba	veth1ce04be	thirsty_meitner


Another way, albeit not perfectly simple, is to first do a “docker ps” and see what ports a container is using.
Then do a “iptables -S -t nat” to see which bridge that port is DNAT:et to.