How to delete Docker images older than a certain time period?
This is the process you can follow for deleting the Docker tags older than a certain date:
- Using AQL: get the list of manifest.json which are older than a certain time period
- For example, you can use this to return the list of manifest.json that are 4 weeks old or more:
- Note: this will also return the repo and path in the search result.
- Then using this REST API you can delete the Docker tag at that particular path that was returned above in the search result
- If a layer is shared between two different tags and if one of the tag is a candidate for the delete in your case above, then the layer will NOT be deleted in the binary storage since it will be still referenced by the other tag.
Other relevant references: