Skip to content

Instantly share code, notes, and snippets.

@NikoWoot
Created January 3, 2015 16:35
Show Gist options
  • Save NikoWoot/d654e044e139209b6bef to your computer and use it in GitHub Desktop.
Save NikoWoot/d654e044e139209b6bef to your computer and use it in GitHub Desktop.
#!/bin/bash
EXPECTED_NUM_ARGS=1;
if [ "$#" -ne $EXPECTED_NUM_ARGS ]; then
# user didn't specify which container ID, assume the latest one
CONTAINER_ID=`/usr/bin/docker ps -q --no-trunc | /bin/sed -n 1p`
/usr/bin/docker exec -it $CONTAINER_ID bash
else
# enter the container the user specified
/usr/bin/docker exec -it $1 bash
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment