Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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

Admittedly I missed the section about boot2docker at in nsenter's README ;-(. Updated the script accordingly. The value-add here is still the bash completion (which I found quite useful)

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