mirror of
https://gist.github.com/jgrodziski/9ed4a17709baad10dbcd4530b60dfcbb
synced 2025-12-21 13:23:11 +01:00
45 lines
1.9 KiB
Bash
45 lines
1.9 KiB
Bash
############################################################################
|
|
# #
|
|
# ------- Useful Docker Aliases -------- #
|
|
# #
|
|
# # Installation : #
|
|
# copy/paste these lines into your .bashrc or .zshrc file #
|
|
# #
|
|
# # Usage: #
|
|
# #
|
|
# dnames : names of all running containers #
|
|
# dipall : IP addresses of all running containers #
|
|
# dex <container>: execute a bash shell inside the running <container> #
|
|
# dps : docker ps #
|
|
# dpsa : docker ps -a #
|
|
# di : docker images #
|
|
# #
|
|
############################################################################
|
|
|
|
function dnames-fn {
|
|
for ID in `docker ps | awk '{print $1}' | grep -v 'CONTAINER'`
|
|
do
|
|
docker inspect $ID | grep Name | head -1 | awk '{print $2}' | sed 's/,//g' | sed 's%/%%g' | sed 's/"//g'
|
|
done
|
|
}
|
|
|
|
function dipall-fn {
|
|
echo "IP address of all named running containers"
|
|
|
|
for DOC in `dnames-fn`
|
|
do
|
|
IP=`docker inspect $DOC | grep -m3 IPAddress | cut -d '"' -f 4 | tr -d "\n"`
|
|
echo $DOC : $IP
|
|
done
|
|
}
|
|
|
|
function dex-fn {
|
|
docker exec -it $1 /bin/bash
|
|
}
|
|
|
|
alias dnames=dnames-fn
|
|
alias dipall=dipall-fn
|
|
alias dex=dex-fn
|
|
alias di="docker images"
|
|
alias dps="docker ps"
|
|
alias dpsa="docker ps -a" |