Skip to content

Instantly share code, notes, and snippets.

@fordhurley
Last active August 29, 2015 14:19
Show Gist options
  • Save fordhurley/06ebc992461787607548 to your computer and use it in GitHub Desktop.
Save fordhurley/06ebc992461787607548 to your computer and use it in GitHub Desktop.
Clean up your boot2docker VM
#!/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