<p>To simplify <strong>deployment</strong> and short term roll-back, it's useful to use a new Docker image tag for each new version to deploy on <strong>Kubernetes</strong>. Without clean-up this means that old images:tags are kept forever.</p>

<p>How can I <strong>list all image:tag that are used by a Kubernetes container</strong> so that I can find all old image:tag that are old and not used to delete them automatically from the <strong>Docker Registry</strong>?</p>

<p>My goal is ideally for <em>Google Container Engine</em> (GKE) to delete unused images a <em>Google Container Registry</em>.</p>

<p>As an alternative approach, you might consider just letting Kubernetes handle reclamation of old images for you.</p>

<p>Presently, the ImageManager handles reclamation of candidate images. See: <a href="http://kubernetes.io/docs/admin/garbage-collection/" rel="noreferrer">Garbage Collection</a></p>

<blockquote>
  <p>Garbage collection is a helpful function of kubelet that will clean up
  unreferenced images and unused containers. kubelet will perform
  garbage collection for containers every minute and garbage collection
  for images every five minutes.</p>
</blockquote>

<p>Configuration is controlled via these two <a href="http://kubernetes.io/docs/admin/kubelet/" rel="noreferrer">kublet cli parameters</a>:</p>

<pre><code>  --image-gc-high-threshold=90: The percent of disk usage after which image garbage collection is always run. Default: 90%
  --image-gc-low-threshold=80: The percent of disk usage before which image garbage collection is never run. Lowest disk usage to garbage collect to. Default: 80%
</code></pre>

<p>The high/low thresholds could be tuned to force collection at an interval that works for you.</p>
