Created
June 6, 2017 20:16
-
-
Save xenithorb/c0fdae80878a010759b2a3d1d76cf608 to your computer and use it in GitHub Desktop.
Useful docker aliases for cleaning things up
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
# These should go in ~/.bashrc or an equivalent area that is sourced into your shell environmemnt | |
# Remove all docker containers running and exited | |
alias docker-rma='__drma() { docker ps -aq "$@" | xargs -r docker rm -f; }; __drma' | |
# Remove all docker images | |
alias docker-rmia='__drmia() { docker images -q "$@" | xargs -r docker rmi -f; }; __drmia' | |
# Remove all custom docker networks | |
alias docker-rmnet='__drmnet() { docker network ls -q -f type=custom "$@" | xargs -r docker network rm; }; __drmnet' | |
# Remove all unused volumes | |
alias docker-rmvol='__drmvol() { docker volume ls -q "$@" | xargs -r docker volume rm; }; __drmvol' | |
# Remove all docker containers and all docker images | |
alias docker-rmall='docker-rma && docker-rmia' | |
# Remove all docker containers, images, custom networks, and volumes | |
alias docker-nuke='docker-rmall; docker-rmnet; docker-rmvol' | |
# Remove only exited containers, unused images, unused networks, and unused volumes | |
alias docker-clean='docker-rma -f status=exited; docker-rmia -f dangling=true; docker-rmnet; docker-rmvol -f dangling=true' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment