In Harbor, how do tag immutability rules freeze release tags while letting moving tags such as latest keep changing?
answer
- project-level policy
- repositories row, tags row
- matching or excluding
- any rule matches: immutable
- blocks re-push, retag, delete
basics
~20 sHarbor tag immutability rules are project-level patterns over repositories and tags. A matching tag can no longer be re-pushed, re-tagged, overwritten by replication or deleted, so excluding moving tags such as latest keeps them mutable.
solid answer
~40 sBy default Harbor lets the same tag be pushed again, which moves it to the new artifact. A project administrator or maintainer adds **tag immutability rules** under the project's policy: each rule has a **Repositories** row and a **Tags** row, each a comma-separated list set to **matching** or **excluding**, with `**` meaning everything. Rules combine with OR, so a tag matched by any rule is immutable, and a project holds at most 15 rules. An immutable tag cannot be overwritten by a re-push, a retag or replication from another registry, and the artifact holding it cannot be deleted. Other tags on that same artifact can still be deleted. To freeze releases but keep aliases moving, match all repositories and set Tags to excluding `latest` and any other alias the team re-points.
go deeper
Recall that Harbor tags can be re-pushed by default and that tag immutability rules stop matching tags from changing.
Explain the Repositories and Tags rows, matching versus excluding, OR logic across rules, and that the artifact behind an immutable tag cannot be deleted.
Show the production edges: excluding aliases inside one broad rule, promotion flows that retag, other tags on a frozen artifact still deletable, and new projects starting unprotected.
Decide which projects must carry immutability rules, which aliases are allowed to move, and who may change the rules, so the guarantee holds across every team's project.
## The problem the rules solve **Harbor** is an open-source container registry that organises repositories into **projects**. The upstream distribution code it builds on does not enforce a mapping between a tag and a digest, so by default users can push an artifact with the same tag again, the tag migrates to the new artifact, and the previous artifact becomes **tagless**. Harbor's docs note that the tag then "can no longer be trusted to identify the image version", while the sha256 digest stays reliable. **Tag immutability rules** let a project refuse that move for chosen tags, so a tag such as `2.4.1` behaves like a release version instead of an alias. ## How a rule is built Rules live at the **project** level: open the project, choose its policy and select **Tag Immutability**. Harbor's how-to asks for at least project administrator rights, and its role table also lets a Maintainer create, delete and deactivate rules. Each rule has two rows: - **Repositories**: a comma-separated list of repositories, set to **matching** or **excluding**. - **Tags**: a comma-separated list of tags, set to **matching** or **excluding**. `**` matches everything. A project can hold at most **15** rules, and an existing rule can be deactivated, edited or deleted from its action menu. Tags caught by a rule show as **Immutable** in the project's repository view. Rules combine with **OR** logic: if any rule matches a tag, that tag is immutable. That matters when designing exceptions, because a broad rule cannot be narrowed by adding a second, narrower rule; the exception has to be written into the broad rule itself with **excluding**. ## What an immutable tag blocks An immutable tag is protected against more than a plain re-push: | Action | Allowed for an immutable tag? | |---|---| | Pushing a different artifact to the same tag | No | | Re-tagging another artifact with that tag | No | | Replication from another registry overwriting it | No | | Deleting the tag or the artifact holding it | No | | Deleting a *different*, non-immutable tag on the same artifact | Yes | The last row surprises people. Harbor lets a tag be deleted without deleting the artifact. In Harbor's own example, `hello-world:v1` is immutable and `hello-world:v2` points at the same digest; `v1` and the artifact cannot be deleted, but `v2` can. ## Freezing releases while aliases keep moving Two common shapes, both from Harbor's examples: 1. **Freeze everything**: Repositories matching `**`, Tags matching `**`. 2. **Freeze everything except named aliases**: Repositories matching `**`, Tags **excluding** a list such as `rc,test,nightly`. For a team that also re-points `latest` and `stable`, the exclusion list names those too. The second shape is the usual answer to the question: every release tag is frozen as soon as it is pushed, while the aliases a team deliberately re-points stay mutable. Deploys should still reference a frozen tag or a digest, never the excluded aliases. ## Checking that the rules hold Rules are only as good as their coverage, so verify them rather than trusting the policy page: 1. Push a test artifact under a tag a rule should freeze, then push a different artifact under the same tag; the second push must fail. 2. Confirm the tag shows as **Immutable** in the project's repository view, and that an excluded alias still moves. 3. Manage rules through Harbor's API for every project, rather than by hand in the interface: the project endpoint `/projects/{project_name_or_id}/immutabletagrules` lists and creates rules, and a robot account can be granted the immutable-tag permissions to do it from automation. A periodic job that lists each project's rules catches the project created last week with none. ## Side effects to plan for - **Promotion by retag** inside Harbor fails if the target tag already exists and is immutable, so a promotion flow has to create new tags rather than re-point frozen ones. - **Mistakes cannot be fixed in place.** A bad image pushed as `2.4.1` stays `2.4.1`; the fix ships as `2.4.2`, which is the point of the rule. - **Rules are per project**, so a new project starts with tags mutable until someone adds rules. Organisations that rely on immutability check every project, not just the one where the rule was first written.
- Why can't a second, narrower Harbor rule carve an exception out of a rule that matches every tag?Harbor combines immutability rules with OR: a tag is immutable if any rule matches it. A rule matching all tags already catches the alias, and nothing a second rule says can un-match it. The exception has to live inside the broad rule, by setting its Tags row to excluding the aliases.
- Harbor freezes every tag by default once it has been pushed.
- An immutable tag only blocks re-pushing; deleting the artifact still works.
- Adding a narrower rule exempts a tag from a broader immutability rule.
- Once one tag on an artifact is immutable, none of its tags can be deleted.
- Immutability rules are set once per Harbor instance, not per project.