4

For weird historical reasons we have 2.14Tb of data in a GCS bucket that stores docker images for Google Container Registry (GCR).

We've used gcloud container images delete <image> to delete thousands of unused images, however stackdriver says there's been no change in the total bytes stored in the underlying GCS bucket.

It looks like gcloud container images delete has deleted the image metadata from the registry, but not the underlying layers.

Is there a way we can garbage collect the unused data from GCS and reduce our monthly bill?

Update after accepting an answer

Here's a chart of the total object size in our GCS bucket - it looks like objects are garbage collected about once every 24 hours (around midday UTC in our case)

enter image description here

3
  • not specific to GCR - in the "normal" registry, delete image only deletes metadata, basically "untagging" stuff. an additional garbage collection is needed. did you check for something like that? (this is how it works in harbor and the docker registry in gitlab)
    – rmalchow
    Aug 20, 2019 at 12:38
  • I can't see any mention of garbage collection in the GCR docs (cloud.google.com/container-registry/docs), but I guess it's possible they run the garbage collection process on a set schedule that hasn't started yet? Aug 20, 2019 at 12:48
  • Ah, you were right. Within 24 hours of deleting the metadata we've seen a big drop in data stored in the GCS bucket. If you want to repost your comment as an answer I'm happy to mark it accepted Aug 20, 2019 at 23:39

1 Answer 1

0

Not specific to GCR - in the "normal" registry (from docker), deleting images only deletes metadata, basically "untagging" stuff. An additional garbage collection is needed. This is how it works in harbor and the docker registry in gitlab.

My interpretation as to why this happens is this: Some of the lower layers might be reusable immediately, and the fact that you deleted some images that reference it doesn't necessarily mean you never want to see them again. So they stay until the GC is invoked explictly (or scheduled GC taks place).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .