title: How to prune docker images based on name and time at the same time
body: <h2>Background</h2>
  <p>I have build machine which creates docker container images daily and uploads it to Azure. For a while there was no problem until build machine run out of disc space.</p>
  <p>So my idea is to prune all old images of my project and leave other images intact (which where already pushed to Azure). There are other images which are old, but have different name (tag) and should not be removed.</p>
  <p>I do not want delete images immediately after successful push to Azure (this is minimal plan).</p>
  <h2>Problem</h2>
  <p>I've found solution how to do deletion of images</p>
  <ul>
  <li><a href="https://docs.docker.com/engine/reference/commandline/rmi/" rel="nofollow noreferrer">based on name</a></li>
  </ul>
  <pre class="lang-sh prettyprint-override"><code>$ docker rmi test1:latest
  # or more complex wher I hoped other filers would work
  $ docker rmi $(docker image ls --format '{{.Repository}}:{{.Tag}}' --filter=&quot;test1:*&quot;)
  </code></pre>
  <ul>
  <li><a href="https://docs.docker.com/engine/reference/commandline/image_prune/#filtering" rel="nofollow noreferrer">based on image age</a> (<a href="https://docs.docker.com/engine/reference/commandline/image_prune/#filtering" rel="nofollow noreferrer">similar SO question</a>)</li>
  </ul>
  <pre class="lang-sh prettyprint-override"><code>$ docker image prune -a --force --filter &quot;until=240h&quot;
  </code></pre>
  <p>But have problem to merge those two criteria together (multiple <code>--filter</code> arguments should work as <code>and</code>).</p>
  <p>What is most annoying docker API is inconsistent. Each docker command has own list of parameters for <code>--filter</code> options. Also documentation of <code>--filter=&quot;lable=&lt;key&gt;=&lt;value&gt;</code> is pretty perfunctory.</p>
  <p>Here is some demo showing this inconsistency:</p>
  <pre class="lang-sh prettyprint-override"><code>$ docker image ls --format '{{.Repository}}:{{.Tag}}' --filter=&quot;reference=test1:*&quot; --filter=&quot;until=20h&quot;
  Error response from daemon: Invalid filter 'until'
  
  $ docker image prune --filter=&quot;until=2200h&quot; 'test1:latest' -a -f
  &quot;docker image prune&quot; accepts no arguments.
  See 'docker image prune --help'.
  
  Usage:  docker image prune [OPTIONS]
  
  Remove unused images
  
  $ docker image prune --filter=&quot;reference=eei-linux-devel-image:old&quot; --filter=&quot;until=200h&quot; -a -f
  Error response from daemon: Invalid filter 'reference'
  </code></pre>
  <p>So what is the best way to delete this images where both creiteria: image name/tag and age are met.</p>