docker networking namespace not visible in ip netns list

前端 未结 3 991
一整个雨季
一整个雨季 2020-12-22 18:30

When I create a new docker container like with

docker run -it -m 560m --cpuset-cpus=1,2 ubuntu sleep 120

and check its namespaces, I can s

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-22 18:59

    That's because docker is not creating the 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, the container's netns namespace can be examined with ip netns ${container_id}, e.g.:

    # e.g. show stats about eth0 inside the container 
    ip netns exec "${container_id}" ip -s link show eth0
    

提交回复
热议问题