Created
April 10, 2014 07:12
-
-
Save djmaze/10350484 to your computer and use it in GitHub Desktop.
Attach to a running docker container on docker >= 0.9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Attach to a running docker container using "dock-attach <CONTAINER ID OR NAME>^ | |
dock_attach() { | |
local name_or_cid=$1 | |
local pid=$(sudo docker inspect --format='{{.State.Pid}}' $name_or_cid) | |
sudo nsenter --target $pid --mount --uts --ipc --net --pid /bin/bash | |
} | |
alias dock-attach=dock_attach |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Technique adapted from http://jpetazzo.github.io/2014/03/23/lxc-attach-nsinit-nsenter-docker-0-9/.