Image Retention
Scenarios
In modern software development, images are generated in pipelines and updated in each iteration. When images of earlier versions are no longer needed, you can delete them by using image retention policies, which can be, manually or periodically triggered. The rules in a policy can be used separately or in a combination.
Constraints
There can only be one retention policy in a given namespace. Each policy has 1 to 15 rules.
Creating an Image Retention Policy
- Log in to the SWR console. In the upper left corner, switch to your region. Click a repository name to go to its details page.
- In the navigation pane, choose O&M Center > Image Retention.
- Click Add Retention Policy in the upper right corner.
- In the displayed dialog box, configure the parameters.
Figure 1 Creating an image retention policy
- Click OK.
Retention Policy Examples
- Example 1:
In the library namespace, for all images, retain the 2 most recently pushed and the 5 most recently pulled tags. The policy needs to be manually triggered.
For example, there are 10 image tags. Image tags 9 and 10 are most recently pushed. Image tags 1 to 5 are most recently pulled. Based on the policy, image tags 6 to 8 will be deleted.
- Example 2:
In the library namespace, retain the tags pushed in the last 3 days for the demo-image-v8 and demo-image-v7 images and the tags pulled in the last day for the demo-image-v6 and demo-image-v5 images. The policy is executed at 00:00 of the first day every month but can also be triggered manually.
Managing Retention Policies
You can:
- Execute a retention policy. To prevent misoperations, you are advised to test a retention policy before executing it for the first time.
- Test a retention policy. You can use it to check whether a policy is in effect but no image tags will be deleted in the test.
- Modify a retention policy. All parameters except Namespace can be modified.
- Delete a retention policy.

- View a retention task. When a retention policy is triggered, only the images that meet the policy will be retained. The following table describes details about a retention task.
Table 2 Retention task parameters Parameter
Description
Trigger Mode
The value is Manual or Automatic.
If you click Execute or Test, the trigger mode is Manual. If the replication is executed periodically based on a schedule, the trigger mode is Automatic.
Status
Task status.
Test
The value can be Yes or No.
If you click Test, the value is Yes. If you click Execute, the value is No. You can use Test to check whether a policy is in effect but no image tags will be deleted in the test.
Tags Deleted
Number of image tags that are deleted based on the policy.
Created
Time when a retention task was triggered.
Ended
Time when a retention task was ended.
Retention Records
Retention records of each image tag, such as the namespace, tag name, and retention results.
Figure 3 Task details
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot