Skip to content

Instantly share code, notes, and snippets.

@Habetdin
Created July 7, 2021 11:58
Show Gist options
  • Save Habetdin/2e3bcfd3c34715537d64b7846648e3ba to your computer and use it in GitHub Desktop.
Save Habetdin/2e3bcfd3c34715537d64b7846648e3ba to your computer and use it in GitHub Desktop.
# 1. Remove all containers including their volumes
docker rm -vf $(docker ps -a -q)
# 2. Remove all images
docker rmi -f $(docker images -a -q)
# (1) and (2) as an one-liner
export _DCKR=$(docker ps -a -q) && [ -n "$_DCKR" ] && docker rm -vf ${_DCKR[@]}; export _DCKR=$(docker images -a -q) && [ -n "$_DCKR" ] && docker rmi -f ${_DCKR[@]}; unset _DCKR
@Habetdin
Copy link
Author

Cleanup unused networks: docker network prune

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment