Skip to content

Instantly share code, notes, and snippets.

@mlgill
Created May 17, 2018 21:48
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 mlgill/aecdef625cea79445ae364e3e93a8168 to your computer and use it in GitHub Desktop.
Save mlgill/aecdef625cea79445ae364e3e93a8168 to your computer and use it in GitHub Desktop.
Docker Cleanup
# Remove all exited containers
docker rm `docker ps -a -q --filter status=exited` 2>/dev/null
# Remove any orphaned containers related to "INSERT_CONTAINER_NAME_HERE"
docker rm `docker ps -a -q --filter ancestor=INSERT_CONTAINER_NAME_HERE` 2>/dev/null
# Remove any orphaned images from aborted/old builds
docker rmi `docker images -q -f "dangling=true"` 2>/dev/null
# Clean up whatever disk-hogging stuff Docker leaves lying aroung
docker system prune --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment