Skip to content

Instantly share code, notes, and snippets.

@scarfacedeb
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save scarfacedeb/4c97d48b41693a9fa67d to your computer and use it in GitHub Desktop.

Select an option

Save scarfacedeb/4c97d48b41693a9fa67d to your computer and use it in GitHub Desktop.
A shortcut to access docker container without sshd
#!/usr/bin/env bash
# A shortcut to access docker container without sshd
#
# See: http://blog.docker.com/2014/06/why-you-dont-need-to-run-sshd-in-docker/
#
# Usage: inspect_docker 7361ceaf8cd3 # container ID
# inspect_docker pensive_turing # container name
if ! [[ $1 ]]; then
echo "You need to specify container ID"
exit 0
fi
PID=$(docker inspect --format {{.State.Pid}} $1)
nsenter --target $PID --mount --uts --ipc --net --pid /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment