Home Docker Prune Cron Job
Post
Cancel

Docker Prune Cron Job

This is a helpful way to keep your containers from running out of space. Create a auto-prune cron job and put it in etc/cron.daily.

1
nano /etc/cron.daily/docker-prune
1
2
3
4
5
6
7
#!/bin/bash

UUID=00000000-0000-0000-0000-0000000000

curl -m 5 --retry 5 https://healthchecks.io/ping/${UUID}/start &>/dev/null
docker system prune --volumes -af
curl -m 5 --retry 5 https://healthchecks.io/ping/${UUID} &>/dev/null

This also includes a ping out to healthcheck.io, which is a really handy thing to track your cron jobs. You can also self host the service.

This post is licensed under CC BY 4.0 by the author.