Protected container tags
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed
- Status: Experiment
The availability of this feature is controlled by a feature flag. For more information, see the history. This feature is available for testing, but not ready for production use.
Control who can push and delete container tags in your project.
By default, users with the Developer role or higher can push and delete image tags in all project container repositories. With tag protection rules, you can:
- Restrict pushing and deleting tags to specific user roles.
- Create up to 5 protection rules per project.
- Apply these rules across all container repositories in your project.
A tag is protected when at least one protection rule matches its name. If multiple rules match, the most restrictive rule applies.
Protected tags cannot be deleted by cleanup policies.
Prerequisites
Before you can use protected container tags:
- You must use the new container registry version:
- GitLab.com: Enabled by default
- GitLab Self-Managed: Enable the metadata database
Create a protection rule
Prerequisites:
- You must have at least the Maintainer role
To create a protection rule:
- On the left sidebar, select Search or go to and find your project.
- Select Settings > Packages and registries.
- Expand Container registry.
- Under Protected container tags, select Add protection rule.
- Complete the fields:
- Protect container tags matching: Enter a regex pattern using RE2 syntax. Patterns must not exceed 100 characters. See regex pattern examples.
- Minimum role allowed to push: Select Maintainer, Owner, or Administrator.
- Minimum role allowed to delete: Select Maintainer, Owner, or Administrator.
- Select Add rule.
The protection rule is created and matching tags are protected.
Regex pattern examples
Example patterns you can use to protect container tags:
Pattern | Description |
---|---|
.* | Protects all tags |
^v.* | Protects tags that start with “v” (like v1.0.0 , v2.1.0-rc1 ) |
\d+\.\d+\.\d+ | Protects semantic version tags (like 1.0.0 , 2.1.0 ) |
^latest$ | Protects the latest tag |
.*-stable$ | Protects tags that end with “-stable” (like 1.0-stable , main-stable ) |
stable|release | Protects tags that contain “stable” or “release” (like 1.0-stable ) |
Delete a protection rule
Prerequisites:
- You must have at least the Maintainer role
To delete a protection rule:
- On the left sidebar, select Search or go to and find your project.
- Select Settings > Packages and registries.
- Expand Container registry.
- Under Protected container tags, next to the protection rule you want to delete, select Delete ( ).
- When prompted for confirmation, select Delete.
The protection rule is deleted and matching tags are no longer protected.
Propagation delay
Rule changes rely on JWT tokens to propagate between services. As a result, changes to protection rules and user access roles might take effect only after current JWT tokens expire. The delay equals the configured token duration:
- Default: 5 minutes
- GitLab.com: 15 minutes
Most container registry clients (including Docker, the GitLab UI, and the API) request a new token for each operation, but custom clients might retain a token for its full validity period.
Image manifest deletions
The GitLab UI and API do not support direct image manifest deletions. Through direct container registry API calls, manifest deletions affect all associated tags.
To ensure tag protection, direct manifest deletion requests are only allowed when:
- Tag protection is disabled
- The user has permission to delete any protected tags
Deleting container images
You cannot delete container images if all the following conditions are true:
- The container image has tags.
- The project has container registry tag protection rules.
- Your access level is lower than the
minimum_access_delete_level
defined in any of the rules.
This restriction applies regardless of whether the rule patterns match the container image tags.
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support