Skip to content

Instantly share code, notes, and snippets.

@rantav
Created May 8, 2018 08:32
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Docker SSH - a simple shell (zsh) function to connect to a running docker container
##############################################
# 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
}
@gayanvirajith
Copy link

Thanks so much!

@AkshayKanchan
Copy link

AkshayKanchan commented Apr 6, 2022

Awesome. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment