Claimed Storage of DOCR climbs with every image push

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?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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<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 run doctl 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:

$ REV=$(git rev-parse HEAD)
$ docker build -t$REV -t .
$ docker push$REV
$ docker push # no new layers to push, should be very fast

You can then easily clean up old images with doctl and run GC to clean up unused layers:

$ doctl registry repo list-tags my-repo
$ doctl registry repo delete-manifest my-repo sha256:<digest>
$ doctl registry gc start

We are working on a few changes to make managing your storage space easier in the future:

  1. We’re working on showing untagged images in the control panel and doctl, so you can delete them directly from there without knowing their digests.
  2. We’re also working on garbage collection previews, to let you know ahead of time how much space you would save by running garbage collection.
  3. On our longer-term roadmap we have image lifecycle configuration. This would allow you to configure automatic cleanup of untagged images.

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