Delete old docker images from all Kubernets Node

11/14/2019

Kubernetes Garbage Collection have a option to delete the images when it reached to a certain percentage of disk usages Link

Is there any way to delete all docker images which is more than three days old and not being used now instead of doing it manually ?

-- Tutai Dalal
docker
garbage-collection
kubernetes

2 Answers

11/14/2019

Follow the below steps

  1. Create a shell script to run docker system prune -f.
  2. Build a docker image using the shell script from above
  3. Deploy a cronjob to clean up daily or twice in a day
-- P Ekambaram
Source: StackOverflow

11/14/2019

You could also simply connect to the node in question and run docker system prune -f there directly.

-- Markoorn
Source: StackOverflow