Skip to content

Instantly share code, notes, and snippets.

@NorikDavtian
Created May 31, 2017 00:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NorikDavtian/5f48c8ff3795c31fddcdf5f8ab2eee7c to your computer and use it in GitHub Desktop.
Save NorikDavtian/5f48c8ff3795c31fddcdf5f8ab2eee7c to your computer and use it in GitHub Desktop.
Docker cleanup bash aliases
# ~/.bash_aliases
# https://www.calazan.com/docker-cleanup-commands/
# Kill all running containers.
alias dockerkillall='docker kill $(docker ps -q)'
# Delete all stopped containers.
alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)'
# Delete all untagged images.
alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)'
# Delete all stopped containers and untagged images.
alias dockerclean='dockercleanc || true && dockercleani'
alias dockerd='dockerkillall && dockerclean'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment