Last active
February 21, 2019 16:16
-
-
Save evitolins/3fdd8e7dce5884682422afa8b8ec063e to your computer and use it in GitHub Desktop.
Helpful aliases to interact with Docker
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 | |
# ------------------------------------ | |
# Get latest container ID | |
alias dl="docker ps -l -q" | |
# Get running containers | |
alias dps="docker ps" | |
# Get all containers | |
alias dpa="docker ps -a" | |
# Get images | |
alias di="docker images" | |
# Stop all running containers | |
dstop() { docker stop $(docker ps -q); } | |
# Remove container(s) (e.g. `drm containerA containerB`) | |
drm() { docker rm } | |
# Remove all containers | |
drma() { docker rm $(docker ps -a -q); } | |
# Stop and Remove all containers | |
alias drmf='docker stop $(docker ps -q) && docker rm $(docker ps -a -q)' | |
# Remove image(s) (e.g., `drmi imageA imageB`) | |
alias drmi="docker rmi" | |
# Remove all images | |
drmia() { docker rmi -f $(docker images -q); } | |
# Dockerfile build with specific tag. (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; } | |
# Attach Container ("SSH into container") | |
dattach() { docker exec -i -t $1 bash } | |
# Follow Container Log ("tail -f" a container's output) | |
alias dfollow="docker logs --follow" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment