Free Up Disk Space in Jenkins (Housekeeping in Jenkins Servers)

If your Jenkins server is building Docker images regularly, it's only a matter of time before disk space starts disappearing. To avoid unexpected storage issues, it's essential to periodically clean up those unused Docker images.

One simple way to automate this cleanup is with a weekly cron job:

0 23 * * 0 /usr/bin/docker system prune -a -f

This cron schedule runs every Sunday at 11:00 PM and executes the following command:

docker system prune -a -f

The command removes all:

  • Unused Docker images
  • Dangling image layers
  • Stopped containers
  • Unused networks
  • Build cache

0 Comments