{"id":9799,"date":"2026-03-03T22:20:31","date_gmt":"2026-03-03T16:50:31","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=9799"},"modified":"2026-09-17T15:03:45","modified_gmt":"2026-09-17T09:33:45","slug":"how-to-configure-a-retention-policy-in-harbor","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-configure-a-retention-policy-in-harbor\/","title":{"rendered":"Harbor Retention Policy: Complete Guide to Artifact Cleanup"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As container images are built and pushed frequently, repositories can quickly accumulate multiple versions of artifacts. Over time, this leads to increased storage usage and unnecessary clutter. To manage this effectively, implementing a retention policy is essential.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In Harbor, retention policies allow you to automatically remove older artifacts while keeping only the required recent versions. In this blog, we will walk through how to configure a retention policy to keep only the last 5 artifacts and how to schedule automatic cleanup.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Harbor should be installed and accessible.<\/li>\n\n\n\n<li>You should have a <strong>Project Admin<\/strong> or <strong>System Admin<\/strong> account.<\/li>\n\n\n\n<li>A Harbor project and repository should already exist.<\/li>\n\n\n\n<li>The repository should contain container images or artifacts.<\/li>\n\n\n\n<li>Ensure the artifacts to be deleted are no longer required.<\/li>\n\n\n\n<li>Confirm the preferred cleanup schedule before enabling automatic cleanup.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Implementation <\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Log in to Harbour<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Login to your Harbor portal using a Project Admin or System Admin account.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Navigate to the Project<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-13.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"423\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-13-1024x423.png\" alt=\"\" class=\"wp-image-9810\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-13-1024x423.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-13-300x124.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-13-768x317.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-13-727x300.png 727w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-13-1200x496.png 1200w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-13.png 1202w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Go to Policy Section<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Inside the project, click on <strong>Policies<\/strong><\/li>\n\n\n\n<li>Under the policy option, you will see <strong>Retention Rules<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-12.png\"><img decoding=\"async\" width=\"865\" height=\"327\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-12.png\" alt=\"\" class=\"wp-image-9806\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-12.png 865w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-12-300x113.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-12-768x290.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-12-794x300.png 794w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here, you can update or configure the retention rules.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Add a Retention Rule<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">1. Click on <strong>Add Rule<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Now provide the required details:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Repository<\/strong>: Select a specific repository OR use <code>**<\/code> to apply to all repositories<\/li>\n\n\n\n<li><strong>Tags<\/strong>: Use <code>**<\/code> to include all tags<\/li>\n\n\n\n<li><strong>Rule Type<\/strong>: Select <strong>retain the most recently pushed # of artifacts<\/strong><\/li>\n\n\n\n<li><strong>Number<\/strong>: 5 ( based on the requirement)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">3. Click <strong>Add<\/strong><br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-10.png\"><img decoding=\"async\" width=\"966\" height=\"576\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-10.png\" alt=\"\" class=\"wp-image-9804\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-10.png 966w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-10-300x179.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-10-768x458.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-10-503x300.png 503w\" sizes=\"(max-width: 966px) 100vw, 966px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After adding the rule, click <strong>ADD<\/strong> to apply the retention policy.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Schedule Automatic Cleanup<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the same <strong>Retention<\/strong> section, there is another option called <strong>Schedule<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using this option:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click on <strong>Schedule<\/strong><\/li>\n\n\n\n<li>Enable scheduling<\/li>\n\n\n\n<li>Set the preferred time (for example, daily at 2:00 AM)<\/li>\n\n\n\n<li>Save the schedule<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"853\" height=\"392\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-11.png\" alt=\"\" class=\"wp-image-9805\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-11.png 853w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-11-300x138.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-11-768x353.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/02\/image-11-653x300.png 653w\" sizes=\"(max-width: 853px) 100vw, 853px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This allows Harbor to automatically clean up old artifacts based on the retention rule at the scheduled time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Retention policies in Harbor provide an efficient way to control artifact storage and maintain repository hygiene. By configuring a rule to keep only the last 5 artifacts and scheduling automatic cleanup, you ensure that your container registry remains optimized and well-managed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Implementing proper retention and scheduling policies is a best practice for maintaining a stable and scalable container registry environment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. What is a Harbor retention policy?<\/strong><br>A Harbor retention policy automatically removes older artifacts based on the rules you configure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Can I keep only the latest 5 artifacts in Harbor?<\/strong><br>Yes. You can create a rule to retain the <strong>5 most recently pushed artifacts<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Can the retention rule apply to all repositories?<\/strong><br>Yes. You can use <code>**<\/code> to apply the rule to all repositories in the project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-add-a-disk-quota-for-harbor-projects\/\">How to Add a Disk Quota for Harbor Projects<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/harbor-dockerhub-backup-and-restore-guide\/\">Harbor \u2013 Dockerhub Backup and Restore Guide<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to our experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Looking for the right technology solution for your business?. Our experts can help with&nbsp;web hosting, domain registration, DevOps and cloud, software development, web applications, mobile applications, and enterprise solutions. Get in touch with our team&nbsp;<a href=\"https:\/\/pheonixsolutions.com\/contact\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction As container images are built and pushed frequently, repositories can quickly accumulate multiple versions of artifacts. Over time, this [&hellip;]<\/p>\n","protected":false},"author":510,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[1073,1072],"class_list":["post-9799","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-docker-harbor","tag-docker-harbor-retention-policy","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-2y3","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/510"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=9799"}],"version-history":[{"count":5,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9799\/revisions"}],"predecessor-version":[{"id":11828,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9799\/revisions\/11828"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=9799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=9799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=9799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}