Created
November 30, 2019 12:44
-
-
Save kytta/461ae43c2cef494f44e8d322606dc778 to your computer and use it in GitHub Desktop.
Docker Deep Clean — a script to remove all unused Docker containers, images and volumes
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 | |
echo "Removing exited containers..." | |
echo "=============================" | |
docker ps --filter status=dead --filter status=exited -aq | xargs docker rm -v | |
echo "" | |
echo "Removing unused images..." | |
echo "=========================" | |
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs docker rmi | |
echo "" | |
echo "Removing unused volumes..." | |
echo "==========================" | |
docker volume ls -qf dangling=true | xargs docker volume rm | |
echo "" | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cred to @mlebkowski for his post