Saturday, July 18, 2015

How to install 'nsenter' to host Docker ?

How to install it?

docker run -v /usr/local/bin:/target jpetazzo/nsenter 
This will install nsenter in /usr/local/bin and you will be able to use it immediately. nsenter might also be available in your distro (in the util-linux package).

 

How do I use it?

First, figure out the PID of the container you want to enter:
PID=$(docker inspect --format {{.State.Pid}} container-name)
Then enter the container:
nsenter --target $PID --mount --uts --ipc --net --pid
 You will get a shell inside the container. That’s it. If you want to run a specific script or program in an automated manner, add it as argument tonsenter. It works a bit like chroot, except that it works with containers instead of plain directories.

https://blog.docker.com/tag/nsenter/ 

No comments: