I got four images that I push to my DOCR when deploying a new version. They accumulate a space of ~1.3GB.
For now I am tagging the images with latest
because I am just trying out DO.
But for some reason, with each push the claimed storage of the DOCR keeps growing. I am now at 14.57 GB even though I still only have those 4 images with each having one tag.
Is this is a bug in the DOCR?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
This is expected behavior, and not specific to DOCR, but it is a bit confusing.
Images in a container registry can be accessed in two ways: by tag or by digest. The digest is an immutable reference to the image based on its contents, and is the “canonical” way to reference an image. A tag is a mutable, human-friendly reference to a digest. You can pull (or push) images by digest using
docker pull registry.digitalocean.com/my-registry/my-repo@sha256:<digest>
.When you push a new image using an existing tag, the tag gets updated but the old image doesn’t go away: it’s still accessible by its digest. DOCR doesn’t automatically clean up untagged images, since it’s completely valid to reference them directly by their digests.
To reduce your storage usage, you’ll need to clean up the untagged images and then run garbage collection. You can delete an image by digest using the
doctl registry repo delete-manifest
command, or with tools such as reg. Unfortunately, at the moment there isn’t a great way to see the digests of untagged images in your registry (see below for future work that will address this). Once you’ve deleted images by digest, you can rundoctl registry gc start
to kick off garbage collection, which will clean up any layers that are no longer in use by any image.I’d suggest modifying your workflow a bit to make cleanup easier. If you push images with unique tags (e.g., based on the git commit hash or some other unique identifier at build time), you can clean them up more easily after you push a new version. You can still use the latest tag additionally, and doing so won’t increase your storage usage at all. For example, if building from a git repository you could do:
You can then easily clean up old images with
doctl
and run GC to clean up unused layers:We are working on a few changes to make managing your storage space easier in the future:
Hope this is helpful - please do reply if you have any other questions about DOCR!
– Adam
I tried what Adam mentioned, it works for latest, but I still see gc have a lot of things but when I do doctl registry repo list, nothing is listed.
Really looking forward to the changes.
For those interested, I have written a github action that prunes old tags.
See at https://github.com/marketplace/actions/digitalocean-registry-prune-old-tags
Hi Adam, I changed the workflow using version numbers now. But in the UI I still only see the latest tag and am not able to delete the old one. For example, I have pushed version 0.0.4 and 0.0.5, but I only see 0.0.5.