Skip to content

Instantly share code, notes, and snippets.

@cpuguy83
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpuguy83/9762945 to your computer and use it in GitHub Desktop.
Save cpuguy83/9762945 to your computer and use it in GitHub Desktop.
More easily attach to container using nsinit and container name
#!/bin/bash
attach_container() {
id=$(docker inspect --format '{{ .ID }}' $1)
cd /var/lib/docker/execdriver/native/${id}
if [ ! -z $2 ]; then
prog="${*:2}"
else
prog=bash
fi
nsinit exec $prog
}
attach_container $1 ${*:2}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment