Created
January 15, 2018 22:56
-
-
Save cmattoon/7e81b1a007169b1631948bb3098b111c to your computer and use it in GitHub Desktop.
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 | |
# 0 * * * * /usr/local/bin/docker-cleanup.cron.sh > /var/log/docker-cleanup.log 2> /var/log/docker-cleanup.err.log | |
cleanup_images() { | |
echo "Cleaning up images" | |
docker rmi -f $(docker images -af dangling=true -q) | |
} | |
cleanup_containers() { | |
echo "Cleaning up containers" | |
docker rm -f $(docker ps -af status=exited -q) | |
} | |
cleanup_volumes() { | |
echo "Cleaning up volumes" | |
docker volume rm $(docker volume ls -f dangling=true -q) | |
} | |
cleanup_containers | |
cleanup_images | |
cleanup_volumes | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment