Created
May 8, 2018 08:32
-
-
Save rantav/c572f5ae9cb7653f33d3d01e52c31bc4 to your computer and use it in GitHub Desktop.
Docker SSH - a simple shell (zsh) function to connect to a running docker container
This file contains 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
############################################## | |
# Add this to your .zshrc | |
# | |
# And then: | |
# $ docker ps | |
# => find your container ID or name and | |
# $ docker-ssh <containerID or containerName> | |
# | |
############################################## | |
docker-ssh() { | |
if (( $# == 0 )) | |
then | |
echo "USAGE: docker_ssh <container name | container id>" | |
return | |
fi | |
name=$1 | |
echo "Connecting to $name" | |
docker exec -i -t $name /bin/bash | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much!