Skip to content

Instantly share code, notes, and snippets.

@jakebathman jakebathman/dssh.sh
Last active May 8, 2019

Embed
What would you like to do?
"SSH" into one of your running docker containers
#! /bin/bash
## Setup note:
## Add execution permissions to this file using:
## chmod u+x dssh.sh
unset options i o
opt=( $(docker ps --format '{{.Names}}' | sort | awk '{print v++,$1}') )
# Show the user a list of containers to pick from
container=$(dialog --title "Choose a Docker Container" --menu "\"SSH\" into..." 15 55 10 "${opt[@]}" 3>&1 1>&2 2>&3 3>&- )
if [ -z "$container" ]; then
clear && exit 1;
fi
# Get the container name from the selection
opt_index=$(($container * 2 + 1))
container_name="${opt[$opt_index]}"
# "ssh" into it
clear && docker exec -it "$container_name" bash
@jakebathman

This comment has been minimized.

Copy link
Owner Author

commented May 8, 2019

This is just a quick comment 👍

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.