Prune Docker Images Daily

I am looking at keeping old images cleaned up from a VM that I have access to. I'm looking at keeping storage space minimal is because there is low hard disk space. Let's do this from a daily crontab.

Create a file in /etc/crontab.daily

nano /etc/crontab.daily/docker-prune

In the contents of the file we will insert the following.

#!/bin/bash
podman system prune -af  --filter "until=$((30*24))h"

Allow the file to be executed.

chmod +x /etc/crontab.daily/docker-prune

NOTE: I use Podman instead of Docker but the command above is interchangeable in this instance.