Skip to content

Instantly share code, notes, and snippets.

@lox
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save lox/d210a74d3c2f317786ab to your computer and use it in GitHub Desktop.
Save lox/d210a74d3c2f317786ab to your computer and use it in GitHub Desktop.
Install nsenter and docker-enter on any Ubuntu host
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "You must be root to execute this script" 2>&1
else
PID=$(docker inspect --format "{{ .State.Pid }}" "$1")
nsenter --target $PID --mount --uts --ipc --net --pid
fi
#!/bin/bash
set -e
curl -o util-linux_2.24-1~1_amd64.deb "http://ppa.launchpad.net/78luphr0rnk2nuqimstywepozxn9kl19tqh0tx66b5dki1xxsh5mkz9gl-launchpad-a811i2i3ytqlsztthjth0svbccw8inm65tmkqp9sarr553jq53in4xm1m/util-linux/ubuntu/pool/main/u/util-linux/util-linux_2.24-1~1_amd64.deb"
sudo dpkg --install --ignore-depends=libblkid1,libmount1,libsmartcols1 --force-overwrite util-linux_2.24-1~1_amd64.deb
sudo curl -o /usr/local/bin/docker-enter https://gist.githubusercontent.com/lox/d210a74d3c2f317786ab/raw/docker-enter
sudo chmod +x /usr/local/bin/docker-enter
@lox
Copy link
Author

lox commented Jul 31, 2014

To install:

curl https://gist.githubusercontent.com/lox/d210a74d3c2f317786ab/raw/install-nsenter.sh | bash

@lox
Copy link
Author

lox commented Jul 31, 2014

I'm sure ignoring those dependencies is horrible. The alternative was grabbing a deb from a PPA directly.

@lox
Copy link
Author

lox commented Aug 4, 2014

This turned out to be a terrible idea, instead:

docker run --rm -v /usr/local/bin:/target yungsang/nsinit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment