Last active
February 17, 2022 18:26
-
-
Save Ashwinning/2fd1bfad33cbd287c21fa1b200cab02c to your computer and use it in GitHub Desktop.
Revisions
-
Ashwinning revised this gist
Nov 2, 2016 . No changes.There are no files selected for viewing
-
Ashwinning created this gist
Aug 30, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ # How To Open Another Terminal/Bash Instance In A Running Docker Container Add the following to your bashrc. ```bash #Add another docker window function dock() { if [ "$1" == "-h" ] then #display help printf "Attaches this window as a new terminal (bash) instance to a running docker container\n" printf "Usage: 'dock' or 'dock 6548as846'\n" printf "Accepts container name or id\n" printf "If no ID is given, then attaches to first found process.\n" elif [ $# -eq 0 ] then #Get the first process dockerpid="$(docker ps -q | head -1)" echo $dockerpid sudo docker exec -i -t $dockerpid /bin/bash elif [ "$1" != "-h" ] then #Open terminal in that process sudo docker exec -i -t $1 /bin/bash fi } ```