Skip to content

Instantly share code, notes, and snippets.

@appleshan
Forked from Jamesits/docker_cleanup.sh
Created October 13, 2021 03:46
Show Gist options
  • Select an option

  • Save appleshan/c66bfb54e4dae0ab4909ba9a22a3d7d8 to your computer and use it in GitHub Desktop.

Select an option

Save appleshan/c66bfb54e4dae0ab4909ba9a22a3d7d8 to your computer and use it in GitHub Desktop.
Docker cleanup unused things
#!/usr/bin/env bash
# USE WITH CAUTION
# remove all exited containers
docker rm $(docker ps -a -f status=exited -f status=created -q)
# remove dangling volumes
docker volume rm $(docker volume ls -f dangling=true -q)
# remove all unused images
docker rmi $(docker images -a -q)
# remove dangling images only
docker rmi $(docker images -f dangling=true -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment