I have the next scenario:
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
otherRegistries.. other Tags. otherIds. otherDates.. ...
For this scenario I need to implement a process which deletes all the docker images tagged with for the registry.someRegistry, but not the one tagged with latest. I have to call this process from my program so I don't have idea about Ids.
After run the process the result should be:
Repository TAG IMAGE_ID CREATED SIZE
registry.someRegistry. latest fa8767676 5 hours ago 119MB
otherRegistries.. other Tags. otherIds. otherDates.. ...
I tried the next commands:
docker rmi --force $(docker images -q 'registry.someRegistry' | uniq)
But this command deletes all the docker images for the registry.someRegistry
Is there the possibility to add another filter to exclude the image tagged with latest?
I know that docker image prune remove all the dangling images, but I need to remove just the ones for the registry.someRegistry.
Any ideas?