Created
September 11, 2017 14:42
-
-
Save DaoWen/2a6e72789d8f6fecda74f829273016f7 to your computer and use it in GitHub Desktop.
Clean up inactive docker instances and images
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 | |
# Remove unused instances | |
dead_instances="$(docker ps -aq -f status=exited)" | |
[ "$dead_instances" ] && docker rm $dead_instances | |
# Remove unused images | |
dead_images="$(docker image ls | awk '/^<none> +<none>/ { print $3 }')" | |
[ "$dead_images" ] && docker rmi $dead_images |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment