Last active
June 29, 2023 18:54
-
-
Save milansimek/a982570e335a27ae430779a21ccd66fa to your computer and use it in GitHub Desktop.
Docker quick bash shell in running container. Allows you to type 'dbash container_name' to directly enter bash in container
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 characters
| #!/bin/bash | |
| #Place this file in the following folder: | |
| #/usr/local/bin/ | |
| # now run `dbash container_name` to enter bash shell in container | |
| # or `dbash [tab][tab]` to use the autocomplete functionality | |
| docker exec -t -i $1 env TERM=xterm bash | |
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 characters
| #!/bin/bash | |
| #Place this file in the following folder: | |
| #/usr/share/bash-completion/completions/ | |
| #IMPORTANT: Filename = dbash | |
| #you might have to run the following command once: | |
| #source /usr/share/bash-completion/completions/dbash | |
| _dbash() | |
| { | |
| local cur=${COMP_WORDS[COMP_CWORD]} | |
| CONTAINERS=`docker ps --format '{{.Names}}'` | |
| COMPREPLY=( $(compgen -W "$CONTAINERS" -- $cur) ) | |
| } | |
| dbash(){ | |
| docker exec -t -i $1 env TERM=xterm bash | |
| } | |
| complete -F _dbash dbash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment