How to check the network namespace with overlay networking

I have manged to setup a three nodes overlay network environment, 1. consul node, 2. swarm master 3. swarm slave.
the multi-host networking works as expected.

When i was trying to deep dive into the overlay network mechanism, from /var/run/docker/netns/, it shows:
root@ubuntu1:/var/run/docker/netns# ls /var/run/docker/netns/
22265cd326d8 2-e6bd07dcef 3f753c31a708 5-53206a655f 9b0db332c3f0 d918fe481a28

my question is how to check the contents within 2-e6bd07dcef or 5-53206a655f?
since 2-e6bd07dcef or 5-53206a655f do not belong to a specif container process, the common way of ln -s /proc/$pid/ns/net /var/run/netns doesnot work. so i have no idea to how to reach it. can you provide some help?

Thanks a lot!

Hi,

You can use nsenter to enter a particular network namespaceā€¦

nsenter --net=/var/run/docker/netns/

-Santhosh.

The namespaces marked with x-{id} represents network namespace managed by the overlay network driver for its operation (such as creating a bridge, terminating vxlan tunnel, etcā€¦). They donā€™t represent the container network namespace. Since it is managed by the driver, it is not recommended to manipulate anything within this namespace. But if you are curious on the deep dive, then you can use the ā€œnsenterā€ tool to understand more about this internal namespace.

Example : nsenter -net=/var/run/docker/netns/2-e6bd07dcef ifconfig

1 Like

Hi sanjmej,

thanks for the information. but seems it does not work for this case, nsenter always response as below:
root@ubuntu1:~# nsenter --net=/var/run/docker/netns/1-53206a655f ifconfig
nsenter: reassociate to namespace ā€˜ns/netā€™ failed: Invalid argument

Thanks for the kindly response.

I tried it but failed, see following:
root@ubuntu1:~# ll /var/run/docker/netns/
total 0
drwxr-xr-x 2 root root 160 May 17 18:09 ./
drwx------ 4 root root 80 May 17 18:09 ā€¦/
-rw-rā€“r-- 1 root root 0 May 17 18:09 1-53206a655f
-rw-rā€“r-- 1 root root 0 May 17 18:09 1-e6bd07dcef
-rw-rā€“r-- 1 root root 0 May 17 18:09 322fbc981d4b
-rw-rā€“r-- 1 root root 0 May 17 18:09 7c1f3be569c9
-rw-rā€“r-- 1 root root 0 May 17 18:09 ba9cc9a5ea64
-rw-rā€“r-- 1 root root 0 May 17 18:09 d211dec9dcd9
root@ubuntu1:~# nsenter --net=/var/run/docker/netns/7c1f3be569c9 ifconfig
nsenter: reassociate to namespace ā€˜ns/netā€™ failed: Invalid argument
root@ubuntu1:~# nsenter --net=/var/run/docker/netns/1-53206a655f ifconfig
nsenter: reassociate to namespace ā€˜ns/netā€™ failed: Invalid argument
root@ubuntu1:~# nsenter --net=/var/run/docker/netns/1-e6bd07dcef ifconfig
nsenter: reassociate to namespace ā€˜ns/netā€™ failed: Invalid argument
root@ubuntu1:~#

Reboot the host and retried it, the same failure still happened.

Any further comments?

Hi @jialiang,

Did you manage to find out what was going wrong? Iā€™m running into the same issue and have no clue on how to continue.

Best regards,

Hi @mavenugo

It seems @jialiang, pmadrid and me run into the same problem, could you please help?

Thanks,

Problem solved, please refer to link: Unable to check Docker overlay network namespace