Skip to content

Instantly share code, notes, and snippets.

@theothermattm
Created February 25, 2015 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theothermattm/872c1619f1acd2b00033 to your computer and use it in GitHub Desktop.
Save theothermattm/872c1619f1acd2b00033 to your computer and use it in GitHub Desktop.
Attach to a docker image by image name
# attaches to the first running docker container containing the name passed
# in as the first argument to the command
# example: attachto projects
function attachto () {
echo "Attaching to first running docker container with name: $1 You might need to press ctrl+c to start entering commands..."
docker attach $( docker ps | grep $1 | head -n 1 | cut -d' ' -f1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment