Last active
October 16, 2017 11:22
-
-
Save rickmak/b337cede9efb71fa07864aa35fc1557f to your computer and use it in GitHub Desktop.
Daily cleanup script for docker images and containers
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 | |
echo "-- Removing exited containers --\n" | |
docker ps --all --quiet --filter="status=exited" | xargs --no-run-if-empty docker rm --volumes | |
echo "\n\n-- Removing images created older than a week --\n" | |
docker images | grep -v "minute\|hour\|day" | awk '{print $3}' | xargs docker rmi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment