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.
I want to write a bash script that can delete all the docker images with REPOSITORY == none or TAG == none.
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.
Currently i am using docker rmi {imageId1} {imageId2} … to delete the images. Your help will be appreciated; Thank you.
2
Answers
Use bash command:
This command gets all image IDs that have tag none and then removes them, if the image is being used anywhere use --force flag to forcefully delete.
You can also try :