Skip to content

Instantly share code, notes, and snippets.

@gilangvperdana
Created August 20, 2022 11:56
Show Gist options
  • Save gilangvperdana/7b37ef06a11fa4408bce6ee574f00c3c to your computer and use it in GitHub Desktop.
Save gilangvperdana/7b37ef06a11fa4408bce6ee574f00c3c to your computer and use it in GitHub Desktop.
Auto Prune Unused Image Kubernetes with Docker Runtime

Auto Prune Unused Image Kubernetes with Docker Runtime

This is some general bash for daily prune unused images on Kubernetes

Execution

Make cron

cd /etc/cron.daily
sudo nano docker-prune

Make simply bash

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

Give a +x permission

sudo chmod +x /etc/cron.daily/docker-prune

Verify to Trigger Daily Backup

run-parts /etc/cron.daily
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment