Created
April 30, 2020 14:38
-
-
Save v5tech/64a681e1050c0536c9ab854ada535606 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
# Docker aliases (shortcuts) and function | |
# List all containers by status using custom format | |
alias dpsa='docker ps -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}"' | |
# Removes a container, it requires the container name \ ID as parameter | |
alias drm='docker rm -f' | |
# Removes an image, it requires the image name \ ID as parameter | |
alias drmi='docker rmi' | |
# Lists all images by repository sorted by tag name | |
alias dimg='docker image ls --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}" | sort' | |
# Lists all persistent volumes | |
alias dvlm='docker volume ls' | |
# Diplays a container log, it requires the image name \ ID as parameter | |
alias dlgs='docker logs' | |
# Streams a container log, it requires the image name \ ID as parameter | |
alias dlgsf='docker logs -f' | |
# Initiates a session withing a container, it requires the image name \ ID as parameter followed by the word "bash" | |
alias dterm='docker exec -it' | |
# Starts a container, it requires the image name \ ID as parameter | |
alias dstrt='docker start' | |
# Stops a container, it requires the image name \ ID as parameter | |
alias dstp='docker stop' | |
# Get latest container ID | |
alias dl="docker ps -l -q" | |
# Get container process | |
alias dps="docker ps" | |
# Get process included stop container | |
alias dpa="docker ps -a" | |
# Get images | |
alias di="docker images" | |
# Get container IP | |
alias dip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'" | |
# Run deamonized container, e.g., $dkd base /bin/echo hello | |
alias dkd="docker run -d -P" | |
# Run interactive container, e.g., $dki base /bin/bash | |
alias dki="docker run -i -t -P" | |
# Execute interactive container, e.g., $dex base /bin/bash | |
alias dex="docker exec -i -t" | |
# Stop all containers | |
dstop() { docker stop $(docker ps -a -q); } | |
# Remove all containers | |
drm() { docker rm $(docker ps -a -q); } | |
# Stop and Remove all containers | |
alias drmf='docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)' | |
# Remove all images | |
dri() { docker rmi $(docker images -q); } | |
# Dockerfile build, e.g., $dbu tcnksm/test | |
dbu() { docker build -t=$1 .; } | |
# Show all alias related docker | |
dalias() { alias | grep 'docker' | sed "s/^\([^=]*\)=\(.*\)/\1 => \2/"| sed "s/['|\']//g" | sort; } | |
# Bash into running container | |
dbash() { docker exec -it $(docker ps -aqf "name=$1") bash; } | |
https://github.com/tcnksm/docker-alias/blob/master/zshrc | |
https://www.sqlservercentral.com/articles/creating-aliases-for-most-command-docker-commands |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment