Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:05
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rhuss/a8a40bd143001fd5c83c to your computer and use it in GitHub Desktop.
nsenter with boot2docker
usage ()
cat <<EOF
docker-enter -- Enter a running container via boot2docker and nsenter
Usage: docker-enter <container_name_or_ID> [command]
See for details.
if [ $# -eq 0 ]
exit 1
boot2docker ssh 'which nsenter 2>&1 >/dev/null || sudo docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter'
boot2docker ssh -t sudo docker-enter $@
_get_comp_words_by_ref -n : cur prev words cword
local containers="$(docker 2>/dev/null ps -q )"
local names="$(docker 2>/dev/null inspect --format '{{.Name}}' $containers | sed 's,^/,,')"
COMPREPLY=( $(compgen -W "$names $containers" -- "$cur") )
complete -F _containers docker-enter
Copy link

rhuss commented Sep 1, 2014

Copy to $SOME_DIR_IN_PATH/docker_enter and to ~/.bash_completion_scripts/ or /usr/local/etc/bash_completion.d (or wherever you bash completion scripts are stored)

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