Docker Community Forums

Share and learn in the Docker community.

How to check the network namespace with overlay networking


(Jialiang) #1

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!


(Sanimej) #2

Hi,

You can use nsenter to enter a particular network namespace…

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

-Santhosh.


(Mavenugo) #3

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


(Jialiang) #5

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


(Jialiang) #6

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?


(Pmadrid) #7

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,


(Baiwang) #8

Hi @mavenugo

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

Thanks,


(Baiwang) #9

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