Last active
August 29, 2015 14:19
-
-
Save fordhurley/06ebc992461787607548 to your computer and use it in GitHub Desktop.
Clean up your boot2docker VM
This file contains hidden or 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 | |
remove_exited_containers() { | |
docker ps -a -q | xargs -n 1 -I {} docker rm {} | |
} | |
remove_untagged_images() { | |
docker rmi $(docker images --filter dangling=true -q) | |
} | |
case "$1" in | |
"containers") | |
remove_exited_containers | |
;; | |
"images") | |
remove_untagged_images | |
;; | |
"all") | |
remove_exited_containers | |
remove_untagged_images | |
;; | |
*) | |
echo "Usage: $0 COMMAND" | |
echo | |
echo "Available commands:" | |
echo " containers: remove exited containers (data will be lost)" | |
echo " images: remove untagged images" | |
echo " all" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment