I would like to ask if it's possible to delete docker images for its tag or the created label, I have something like this:
Repository TAG IMAGE_ID CREATED SIZE
registry.someRegistry. latest fa8767676 5 hours ago 119MB
registry.someRegistry. <none> 878787874 29 hours ago 119MB
registry.someRegistry. <none> jkj7jjjk4 2 days ago 119MB
registry.someRegistry. <none> d99090iii 3 days ago 119MB
I need to remove all the images but not the most recently one in this case is the one tagged with latest or the one with the most recent Created date. I can use the next command to delete all the images until 5 hours of creation, but it's not appropriate, because I could delete more images not just the last one, would be better to delete images by the tag=latest.
docker image prune -a --force --filter "until=5h"
I need also an additional filter for the registry I think, in order to remove just the images for the registry I need.
Any good way to achieve that?
CodePudding user response:
The simplest would be the rmi
command, i.e.:
docker rmi 878787874
This is a "remove image" command and uses the IMAGE_ID you list.
CodePudding user response:
you can remove dangling images with filter
docker images --filter dangling=true