阅读 25

登陆到docker容器中的方法之一(需要root权限)

登陆到docker容器中的方法之一(需要root权限)

nsenter

The nsenter tool is part of the util-linux package since version 2.23. It provides access to the namespace of another process. nsenterrequires 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-ncursesmake nsentercp 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


文章分类
后端
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 gxwowoo@163.com 举报,一经查实,本站将立刻删除。
相关推荐