Investigating network problems within docker can be tricky. Let’s see how to get more details how to see the communication between docker and host.

If you are familiar with wireshark and linux, then probably you have also heard about tcpdump. If not, then it is a tool we can use to see what is happening on the interface (network), in our case used by docker to communicate with host, via tcp. The first problem we face is when you run multiple containers then each of them gets a virtual interface with some weird name like veth988ee0c. But which one actually coresponds to which container?

Firstly, lets assume we have a running container called notebook (I use docker mainly for running jupyter notebooks, that’s where the names comes from). The simplest way to list the interface used for communication with host is by running the command below, we do not even need to enter the cotainer (attach, or launch bash).

In this case I have only two interfaces in docker, probably the most typical case. And I know it communicates with host using eth0. So, let’s identify this interface on the host machine. To do that we need to get ifindex of the interface. We can get it by running (note the eth0 in the path name).

user@host:~$ docker exec notebook cat /sys/class/net/eth0/iflink
7

In my cae it returned number 7. Now we may find interface with the corresponding ifindex value.