0

我阅读的所有内容都使用使用该网络的容器的 PID。不幸的是,容器由于我认为是网络问题而死亡。我想进入网络命名空间并运行命令,而不是在该网络上运行不同的容器。

我的 /var/run/docker/netns/ 文件夹是空的。但是网络是一个桥接网络,出现在docker network ls

4

1 回答 1

2

When a container is started, it gets it's own network namespace unless it is started with --net=none or --net=host. This namespace gets deleted once the container is stopped. So you won't be able to debug anything related to that container's network once it's not running.

You need to check the container logs as to why the container exited.

Anyways here are some relevant sample commands:

pid=`docker inspect -f '{{.State.Pid}}' $container_id`

mkdir -p /var/run/netns
rm -f /var/run/netns/$container_id
ln -sv /proc/$pid/ns/net /var/run/netns/$container_id
nsenter -m -t `pidof dockerd` nsenter --net=/var/run/docker/netns/4-4ef4272ac1 ip link
于 2018-06-06T03:58:02.433 回答