Created
January 1, 2023 21:19
-
-
Save ourway/132f3b7cd8d43b3819b7c80d7eb78eaf to your computer and use it in GitHub Desktop.
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 | |
# Kill all running containers. | |
docker kill $(docker ps -q) | |
# Delete all stopped containers. | |
printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q) | |
# Delete all untagged images. | |
printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true) | |
# Delete all images. | |
printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q) | |
# Delete all volumes. | |
printf "\n>>> Deleting volumes\n\n" && docker volume rm $(docker volume ls -q) | |
# Remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes. | |
printf "\n>>> Deleting unused containers, networks, images and volumes\n\n" && docker system prune -a --volumes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment