title: How to remove all associated containers and an image upon Docker build
body: <p>I'm working on building a Docker image and am wondering if there's a quick way to delete a prior image built from a docker build and remove any previously rendered containers derived from the image during a Docker build.  </p>
  
  <p>I know I can do this separately, by removing all containers (running or stopped) associated with an image by using the ancestor filter:</p>
  
  <p><code>docker rm -f $(docker ps -a -q --filter="ancestor=&lt;image id&gt;")</code></p>
  
  <p>and I also understand how to remove the associated container:</p>
  
  <p><code>docker rmi &lt;image id&gt;</code></p>
  
  <p>However, doing both steps during the next docker build would be ideal.</p>