Last active
June 23, 2016 16:41
-
-
Save bgromov/08b9c240ba793107074b40b7a4006a2b to your computer and use it in GitHub Desktop.
Docker Cleanup Commands
This file contains 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
#!/bin/bash | |
# E.g. ~/.bash_aliases | |
## Docker Cleanup Commands | |
## Credits: https://www.calazan.com/docker-cleanup-commands/ | |
# Kill all running containers | |
alias docker_kill='docker kill $(docker ps -q)' | |
# Stop all running containers | |
alias docker_stop='docker stop $(docker ps -q)' | |
# Delete all stopped containers | |
alias docker_clean='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)' | |
# Stop all running containers and delete them | |
alias docker_clean_stop='docker_stop || docker_clean' | |
# Delete all 'untagged/dangling' (<none>) images | |
# WARNING: also deletes data-only containers! | |
alias docker_clean_images='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)' | |
# Delete all stopped containers and untagged images. | |
alias docker_clean_all='docker_clean_containers || true && docker_clean_images' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment