Docker prune images not used in the last X hours

Viewed 1017

Is there a way to do docker prune image to get rid of images if either they or their intermediary layers have not been used in the last X hours?

The purpose is: Say a build has created intermdiary and final image(F1). A subsequent build can use the intermediary image. While this subsequent build is running, if I run docker image prune -f -a in another window, then Docker will delete the image F1 (assuming it is unused) and it's intermediary images. Thus the build in progress even if it had used intermediary image will have to rebuild the intermediary image. If there is a filter setting on the prune command based on last used then it will be helpful.

1 Answers
Related