登陆到docker容器中的方法之一(需要root权限)
nsenterThe nsenter tool is part of the util-linux package since version 2.23. It provides access to the namespace of another process.nsenter requires root privileges to work properly. Unfortunate
·
nsenter
The nsenter tool is part of the util-linux package since version 2.23. It provides access to the namespace of another process. nsenter requires root privileges to work properly. Unfortunately, util-linux is still at version 2.20 in Ubuntu 14.04. To install the latest version (2.24) proceed as follows:
cd /tmp curl https://www.kernel.org/pub/linux/utils/util-linux/v2.24/util-linux-2.24.tar.gz | tar -zxf- cd util-linux-2.24 ./configure --without-ncurses make nsenter cp nsenter /usr/local/bin |
In order to connect to a container, you have to find out the PID of the first process in the container.
docker inspect --format "{{ .State.Pid }}" <container-id> |
With that PID you can connect to the container:
nsenter --target $PID --mount --uts --ipc --net --pid
更多推荐
已为社区贡献2条内容
所有评论(0)