linux - docker networking namespace not visible in ip netns list -
when create new docker container
docker run -it -m 560m --cpuset-cpus=1,2 ubuntu sleep 120 and check namespaces, can see new namespaces have been created (example pid 7047).
root@dude2:~# ls /proc/7047/ns -la total 0 dr-x--x--x 2 root root 0 jul 7 12:17 . dr-xr-xr-x 9 root root 0 jul 7 12:16 .. lrwxrwxrwx 1 root root 0 jul 7 12:17 ipc -> ipc:[4026532465] lrwxrwxrwx 1 root root 0 jul 7 12:17 mnt -> mnt:[4026532463] lrwxrwxrwx 1 root root 0 jul 7 12:17 net -> net:[4026532299] lrwxrwxrwx 1 root root 0 jul 7 12:17 pid -> pid:[4026532466] lrwxrwxrwx 1 root root 0 jul 7 12:17 user -> user:[4026531837] lrwxrwxrwx 1 root root 0 jul 7 12:17 uts -> uts:[4026532464] root@dude2:~# ls /proc/self/ns -la when check ip netns list cannot see new net namespace.
dude@dude2:~/docker/testroot$ ip netns list dude@dude2:~/docker/testroot$ any idea why?
that's because docker not creating reqired symlink:
# (as root) pid=$(docker inspect -f '{{.state.pid}}' ${container_id}) mkdir -p /var/run/netns/ ln -sft /proc/$pid/ns/net /var/run/netns/$container_id then, container's netns namespace can examined ip netns ${container_id}, e.g.:
# e.g. show stats eth0 inside container ip netns exec "${container_id}" ip -s link show eth0
Comments
Post a Comment