Created
June 4, 2023 19:52
-
-
Save ismailkarsli/dd71cd5ebb3b1a611ddb56b1bdc238c5 to your computer and use it in GitHub Desktop.
Automatically prune docker system when disk limit exceeds
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/sh | |
ROOT_FS_USAGE=$(df -H / | grep -vE 'Filesystem' | awk '{ print $5}' | cut -d'%' -f1) | |
DISK_LIMIT=${DISK_LIMIT:-75} | |
if [ "$ROOT_FS_USAGE" -ge "$DISK_LIMIT" ]; then | |
echo "Cleaning up docker images" | |
docker system prune -af --filter="until=1h" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment