Terminal Deletion of Images: Garbage Collection

A simple delete operation is not enough to remove images – to be precise, their blob files – from the system. When you use a delete button on the artifacts overview page inside a repository, it simply deletes the corresponding item from the GUI. It means that simple deletion does not clean up your storage, and you may be hitting your project quotas even if you do not see a lot of artifacts in there.
To remove blob files from the system and make some space in your repository, you need to perform an operation known as garbage collection.
To access it:

  • Expand Administration in the navigation tab;
  • Click Garbage Collection.

Handling Untagged Artifacts

When you remove a tag from the image, you hide a layer associated with the tag from the Container Registry GUI. The result of the untagging is equal to deletion and, as in the case of deleting an artifact, it does not remove the blob from the system.
Independently of the method you select for garbage collection, make sure to use the slider to specify if you want to include untagged artifacts in the ultimate deletion:

Handling Images That Are Still Uploading

Since some images may take time to upload, there is a mechanism to prevent them from unintentional removal. Any garbage collection operation (including the dry run) only covers images that were not uploaded within the previous two hours.

Garbage Collection Dry Run

Garbage collection takes some time and computing capacity. Besides, since some blob files may be shared between artifacts with identical layers, this operation brings some complexity with it. As a result, a running garbage collection may prevent users from working with your repository normally.
For this reason and to avoid losing data that you may still need, we recommend performing a test execution first: a dry run.

  • Use the Dry Run button to initiate it and wait for the results to appear;

Access Garbage Collecting Log Data

  • Go to the History tab;
  • Find the dry run job that you started;
  • Click on the Log icon;
  • The log data will be displayed in a new browser window; it will list artifact trash candidates and provide a recommendation for whether or not to run a garbage collection.

2021-09-08T15:50:18Z [INFO] [/jobservice/job/impl/gc/garbage_collection.go:145]: Garbage Collection parameters: [delete_untagged: false, dry_run: true, time_window: 2]
2021-09-08T15:50:18Z [INFO] [/jobservice/job/impl/gc/garbage_collection.go:155]: start to run gc in job.
2021-09-08T15:50:18Z [INFO] [/jobservice/job/impl/gc/garbage_collection.go:411]: artifact trash candidates.
2021-09-08T15:50:18Z [INFO] [/jobservice/job/impl/gc/garbage_collection.go:413]: ID-1 MediaType-application/vnd.docker.container.image.v1+json ManifestMediaType-application/vnd.docker.distribution.manifest.v2+json RepositoryName-library/gc_test Digest-sha256:1b26826f602946860c279fce658f31050cff2c596583af237d971f4629b57792 CreationTime-2021-09-08 15:50:13
2021-09-08T15:50:18Z [INFO] [/jobservice/job/impl/gc/garbage_collection.go:203]: no need to execute GC as there is no non referenced artifacts.
2021-09-08T15:50:18Z [INFO] [/jobservice/job/impl/gc/garbage_collection.go:174]: success to run gc in job.

You can also see how much space will be freed after the execution.

Run Garbage Collection

Use the GC Now button to run a real garbage collection. You can access the History tab to monitor the execution and then look into the log file when the job is finished.

Schedule Garbage Collection

To schedule a garbage collection:

  • Click on Edit next to Schedule to GC;
  • Select a schedule or type in a CRON-formatted schedule;
  • Hit Save.