Last active
December 4, 2020 21:54
-
-
Save eschen42/86a185ef14dfc2701f2eeb66300e50ea to your computer and use it in GitHub Desktop.
Remove exited containers, orphaned volumes, and unnamed repositories
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/sh | |
echo find and destroy exited containers | |
echo --- | |
sudo docker rm $( echo $( \ | |
sudo docker ps -a --filter="status=exited" -q) ) | |
echo ... | |
echo find and destroy unnamed orphaned volumes | |
echo --- | |
sudo docker volume rm $( \ | |
sudo docker volume ls -q -f 'dangling=true' | grep -v '[g-zA-Z-]' ) | |
echo ... | |
echo "tabula rasa!" |
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 | |
# find and remove images with no tag and no repository name | |
sudo docker rmi $(sudo docker images | grep '^.none .*none' | sed -e 's/ [ ]*/:/g' | cut -f 3 -d :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment