Skip to main content

Immutable tags and tag immutability rules

An immutable tag always points to the same image: pushing a new image to it fails, and so does deleting it. Make release tags such as v1.2.0 immutable, and a deployment that names api:v1.2.0 can never get a different image than the one you tested. A project can make every tag immutable with the Immutable tags setting, or protect only some tags with tag immutability rules.

At a glance​

What it protectsA tag from being pushed over (moved to another image) or deleted, and its image from being deleted
Project wideThe Immutable tags setting: every tag of every repository, latest included
SelectiveTag immutability rules with repository and tag patterns, in the Policy tab
Rules per projectUp to 15, the Immutable tags setting counting as one
RetentionRetention policies never delete an image an immutability rule protects
Turning it offDisable or delete the rule, or turn the setting off. Existing tags can then be moved or deleted again
Not availableIn the apps project

Why make tags immutable?​

Tags are mutable by default: docker push registry.cloider.com/acme/api:1.0 replaces whatever 1.0 pointed to. That is convenient for latest and staging, but dangerous for releases:

  • A rebuild pushed by mistake can silently change what 1.0 means, and the next pod restart runs code nobody tested.
  • Two clusters running api:1.0 can end up on different images.
  • Audits and rollbacks rely on a version meaning exactly one build.

Immutable tags remove that risk. The alternative is to pin images by digest (api@sha256:...), which is exact but hard to read.

Option 1: Make every tag immutable​

The Immutable tags setting protects every tag in every repository of the project, including latest. Use it for a project that only holds releases, such as acme-releases, where nothing is ever pushed twice.

When you create the project, turn on Immutable tags in the form. For an existing project:

  1. Open the project and go to the Settings tab.
  2. Turn on Immutable Tags.
  3. In Make Tags Immutable, read the warning (Every tag in the project will keep pointing to the image it was pushed with. Pushing over a tag, latest included, or deleting it will fail.) and click Make immutable.

Turning it off needs no confirmation.

How the setting relates to the rules​

The Immutable tags setting is an immutability rule: repositories matching **, tags matching **. Turning the setting on adds that rule (or enables it if it exists but is disabled), and turning it off deletes it. That is why:

  • the rule appears in the Policy tab's Tag Immutability list,
  • adding the same rule by hand in the Policy tab turns the setting on,
  • the setting counts toward the 15 rule limit, and can't be turned on when a project already has 15 other rules.

Option 2: Protect only some tags with rules​

Rules protect the tags that match their patterns and leave the others mutable. The most common setup: release tags immutable, latest, branch and cache tags movable.

Patterns​

Each rule has a repositories selector and a tags selector, each matching or excluding a list of up to 20 patterns. * stays within one path segment, ** crosses them, ? is any one character, and [...] is a character class.

GoalRepositoriesTags
Version tags starting with v everywherematching **matching v*
Semantic versions like 1.4.0 everywherematching **matching [0-9]*
Every tag except moving onesmatching **excluding latest, main, staging, buildcache
Every tag of production repositoriesmatching prod/**matching **
Release tags of every repository but sandboxexcluding sandboxmatching v*, release-*

Each rule is worked out on its own, and a tag that any rule picks is protected.

Add a rule​

  1. Open the project and go to the Policy tab.
  2. In Tag Immutability, click Add rule.
  3. For the repositories: matching **.
  4. Tags: matching v*. Separate several patterns with commas.
  5. Click Add rule.

The rule reads In repositories matching **, tags matching v* can't be deleted or pushed over, with an Enabled switch, and edit and delete buttons.

List, change, disable and delete rules​

In the Policy tab, Tag Immutability:

  • The Enabled switch turns a rule off without deleting it. Its tags can be pushed over and deleted while it is off.
  • The pencil opens Edit Tag Immutability Rule; click Save rule.
  • The trash icon asks Delete this immutability rule? The tags it protects can be deleted and pushed over again.

What an immutable tag changes in practice​

You doWith a mutable tagWith an immutable tag
docker push a new image to an existing tagThe tag moves to the new imageThe push is refused
docker push a new tagWorksWorks
Push the exact same image to the existing tag againWorksMay be refused; push only new tags
Remove the tag (untag)WorksRefused
Delete the imageWorksRefused while any of its tags is protected
Delete the repositoryWorksRefused while it holds protected tags
Retention runDeletes the image if no rule keeps itKeeps it, reported as Kept, immutable

In the dashboard's Repositories tab, a protected tag shows a lock icon (Immutable, a rule in the Policy tab protects it) instead of the remove button, and the delete button of its image is disabled.

Immutable tags and CI pipelines​

A pipeline that pushes latest, a branch tag or a build cache tag on every run fails on the second run if those tags are immutable. Two patterns work well:

  • Unique tags only: tag each build with its commit (sha-4f2a9c1) and releases with their version, never push latest. Then Immutable tags for the whole project is safe.
  • Selective rules: protect v* (or [0-9]*) and leave latest, branch and buildcache tags mutable.

See CI/CD pipelines.

Troubleshooting​

ProblemCause and fix
docker push of a tag fails although the token can pushThe tag already exists and is immutable. Push a new tag, or disable the rule while you fix it
A tag immutability rule protects this tag. Disable the rule in the Policy tab to delete it.You tried to remove a tag or delete an image or repository that a rule protects
The project already has a rule like this one.An identical rule exists. Edit it instead
A project holds at most 15 immutability rules.Combine rules: one rule takes up to 20 patterns
A project holds at most 15 immutability rules, delete one in the Policy tab first.Turning on Immutable tags needs a free rule slot
Enter at least one pattern, ** for allA selector has no pattern
This project holds your apps' images and is managed by Cloider, its policies can't be changed.The apps project's tags are managed by Cloider
This project's policies were changed outside the dashboard, contact support to edit them.Contact support
Invalid ruleThe rule id isn't a number
It doesn't exist any more, reload and try again!The rule was deleted meanwhile

Next steps​