Skip to content

Instantly share code, notes, and snippets.

@ljonesfl ljonesfl/
Last active Feb 9, 2020

What would you like to do?
Shell into a docker container ./ image-name
echo "Looking for $1"
OUT="$(docker ps | awk '{if( $2==container ) print $1}'-v container=$1)"
if [ ${#OUT} -eq 0 ]
echo "Unable to locate a container running the image $1"
exit 1
echo "Executing shell for Container ID:${OUT} running image $1"
docker exec -it ${OUT} bash

This comment has been minimized.

Copy link

c0d3b0t commented Feb 9, 2020

Make the d-s command to be available globally:
chmod +x
sudo mv /usr/local/bin/d-s

And use it:
d-s image-name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.