Skip to content

Instantly share code, notes, and snippets.

@bivas
Created July 27, 2014 08:19
Show Gist options
  • Save bivas/b4b6ab42c01bcc06779e to your computer and use it in GitHub Desktop.
Save bivas/b4b6ab42c01bcc06779e to your computer and use it in GitHub Desktop.
Place this in /etc/profile.d/ folder and you can open a shell in a running Docker container
#!/bin/bash
function docker-sh() {
local __PID=""
__PID=$(docker inspect --format "{{.State.Pid}}" $1)
local __EXIT=$?
if [ $__EXIT -eq 0 ]; then
nsenter --target $__PID --mount --uts --ipc --net --pid
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment