Skip to content

Instantly share code, notes, and snippets.

@olkitu
Last active April 15, 2021 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olkitu/b60c8236686e863ad52e5302855363da to your computer and use it in GitHub Desktop.
Save olkitu/b60c8236686e863ad52e5302855363da to your computer and use it in GitHub Desktop.
Gitlab CI Docker Prune
#!/bin/bash
# Run this daily to cleanup unused images and networks
# chmod +x /etc/cron.daily/docker-clean.sh
# Create new log file
touch /var/log/docker-clean.log
# Delete all unused images and volumes
/usr/bin/docker system prune --volumes -a -f >> /var/log/docker-clean.log
# Delete all unused networks
/usr/bin/docker network prune -f >> /var/log/docker-clean.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment