Skip to content

Instantly share code, notes, and snippets.

@jakebathman jakebathman/
Last active May 8, 2019

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
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;
# Get the container name from the selection
opt_index=$(($container * 2 + 1))
# "ssh" into it
clear && docker exec -it "$container_name" bash

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.