A simple shell script to clean up GitLab Runner images, cache, and remove oldest Docker images.
What it does:
This script automates the process of:
- Cleaning up unused Docker images in the GitLab Runner registry
- Removing unnecessary cache files generated by GitLab Runner
- Deleting oldest Docker images and only keep MAX_IMAGES latest
Run this script on your linux runner:
curl -sL "https://github.com/nh4ttruong/runner-cleanup/raw/main/run.sh" | bashTo automate the script, we'll add it to the cron daily schedule. This way, the script will run automatically every day, keeping your GitLab Runner instances and Docker environments tidy and efficient.
Here's how to add the script to cron:
- Open the cron table for editing:
crontab -e - Add the following line to the file:
For automatically, add it into crontab:
@hourly curl -sL "https://github.com/nh4ttruong/runner-cleanup/raw/main/run.sh" | bashHere are some related projects