Created
May 6, 2026 13:38
-
-
Save ioggstream/4226f3c55df992a95ac48d20aaeccbc7 to your computer and use it in GitHub Desktop.
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
| dip(){ | |
| # Show docker ips | |
| local arg=${1} | |
| if [ -z "$arg" ]; then | |
| arg=$(docker ps -q) | |
| fi | |
| docker inspect --format ' {{.Name}} {{.NetworkSettings.IPAddress}} {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $arg | |
| } | |
| # | |
| # Docker Exec alias with auto-complete | |
| # | |
| dshell(){ | |
| local container="${1##/}" | |
| local command="${2:-/bin/bash}" | |
| docker exec -ti "$container" "$command" || \ | |
| docker compose exec -ti "$container" "$command" | |
| } | |
| _dshell() | |
| { | |
| local cur prev opts | |
| COMPREPLY=() | |
| cur="${COMP_WORDS[COMP_CWORD]}" | |
| prev="${COMP_WORDS[COMP_CWORD-1]}" | |
| opts="$(docker inspect -f '{{.Name}}' $(docker ps -q))" | |
| opts=${opts//\/} | |
| if [[ ${cur} =~ [a-z]+ ]]; then | |
| COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
| return 0 | |
| fi | |
| } | |
| complete -F _dshell dshell | |
| # | |
| # Run a given docker image with a sh entrypoint | |
| # | |
| drun(){ | |
| local last_argument="${@:$#}" | |
| echo Executing: docker run -ti "${@:1:$#}" --entrypoint /bin/sh $last_argument | |
| docker run -ti "${@:1:$#-1}" --entrypoint /bin/sh $last_argument | |
| } | |
| dcode(){ | |
| local last_argument="${@:$#}" | |
| echo Executing: docker run -ti -v $PWD:/code "${@:1:$#}" --entrypoint /bin/sh $last_argument | |
| docker run -ti "${@:1:$#-1}" -w /code -v $PWD:/code --entrypoint /bin/sh $last_argument | |
| } | |
| # | |
| # List network bridges | |
| # | |
| dnets(){ | |
| local arg=${1} | |
| if [ -z "$arg" ]; then | |
| arg=$(docker network ls -q) | |
| fi | |
| docker network inspect --format '{{.Name}} {{range .IPAM.Config}}{{.Subnet}}{{end}}' $arg | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment