Created
October 19, 2016 07:06
-
-
Save kytomaki/d85f1c012cc5c6e3e0007ec91d4f26a5 to your computer and use it in GitHub Desktop.
Cleaning up after docker.
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 | |
# | |
# Create $HOME/.docker-gc/exclude which contains images you do not | |
# wish to remove. | |
# | |
# https://github.com/spotify/docker-gc#excluding-images-from-garbage-collection | |
docker run --rm \ | |
-v /var/run/docker.sock:/var/run/docker.sock \ | |
-v "$HOME"/.docker-gc:/etc/docker-gc \ | |
-e FORCE_CONTAINER_REMOVAL=1 \ | |
-e FORCE_IMAGE_REMOVAL=1 \ | |
-e EXCLUDE_CONTAINERS_FROM_GC=/etc/docker-gc/exclude \ | |
spotify/docker-gc | |
# Remove dangling volumes | |
DANGLING_VOLUMES=$(docker volume ls -qf dangling=true) | |
for VOLUME in $DANGLING_VOLUMES; do | |
docker volume rm "$VOLUME" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment