title: Bash Script to delete specific docker images and containers
body: <p>I work with docker images a lot and create the same image again and again after making changes to the code; so I get a lot of leftover images.</p>
  <p><a href="https://i.stack.imgur.com/zTZL6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zTZL6.png" alt="enter image description here" /></a></p>
  <p>I want to write a bash script that can delete all the docker images with <strong>REPOSITORY == none</strong> or <strong>TAG == none</strong>.
  Sometimes the none docker image is being run by a container so it cannot be deleted; then i want the script to delete the container running the image firstly then remove the image.</p>
  <p>Currently i am using <em><strong>docker rmi {imageId1} {imageId2} ...</strong></em> to delete the images. Your help will be appreciated; Thank you.</p>