title: Kubernetes: How to automatically clean up unused images
body: <p>Due to some internal issues, we need to remove unused images as soon as they become unused.<br>
  I do know it's possible to use <a href="https://kubernetes.io/docs/concepts/cluster-administration/kubelet-garbage-collection/" rel="nofollow noreferrer">Garbage collection</a> but it doesn't offer strict policy as we need. 
  I've come across <a href="https://hub.docker.com/r/meltwater/docker-cleanup/" rel="nofollow noreferrer">this</a> solution but</p>
  
  <ol>
  <li>it's deprecated</li>
  <li>it also removes containers and possible mounted volumes</li>
  </ol>
  
  <p>I was thinking about setting a <code>cron</code> job directly over the nodes to run <code>docker prune</code> but I hope there is a better way</p>
  
  <p>No idea if it makes a difference but we are using AKS</p>