Safeguard
Developer Tools•

How should you tag release container images? Rules and a scheme

OCI tags allow 128 characters from a fixed set. A tagging scheme with version, commit SHA and digest that stays traceable and safe to promote.

Safeguard Security Team
3 min read

Tag release images with an immutable version plus the commit SHA, and deploy by digest. OCI tags may be at most 128 characters and must match a fixed pattern of letters, digits, underscore, period and hyphen. Treat moving tags such as latest as convenience labels, never as the thing production runs.

What the specification allows

The OCI distribution specification says a tag must be at most 128 characters and match this regular expression:

[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}

So a tag cannot start with a period or hyphen, and cannot contain a plus sign or slash. That affects semantic version build metadata: 1.4.0+abc123 is not a legal tag, so many teams write 1.4.0-abc123 or use a separate tag.

A scheme that works

TagExampleMoves?Use
Full version1.4.0NeverThe release name
Version and commit1.4.0-3f9c2abNeverTrace back to source
Minor line1.4YesConvenience for humans
Digestsha256:...NeverWhat deployment references

Only the first two should be trusted. Moving tags are fine for developers, but production manifests should carry the digest.

Steps

  1. Build once per commit and tag with the commit SHA.
  2. On release, add the version tag to the same digest. Do not rebuild.
  3. Record the digest in the release notes and in your change record.
  4. Turn on tag immutability where the registry supports it. See how to make ECR tags immutable.
  5. Reference the digest in deployment manifests, and let a policy reject tag only references. See require image digests with an admission policy.

Why not rebuild per environment

A rebuild produces a new digest, so what you tested is not what you shipped. Promote the same artifact instead: build once, promote the same artifact.

Verify after you push

After a release push, pull the image by its tag on a clean machine and compare the digest to the one in your release record. If they differ, something moved, and you want to know before a customer does. Do the same check after promotion between registries, because a copy that changed the manifest changes the digest and breaks any signature tied to the original.

Tags are also a communication tool. A short, consistent scheme lets support and security staff say exactly which build a customer runs, and lets an advisory reference an unambiguous version. Write the scheme down in the release runbook so it survives staff changes.

Naming mistakes to avoid

  • Reusing a version tag after a fix. Publish a new patch version.
  • Encoding secrets, branch names with slashes or customer names in tags.
  • Using only latest. Nobody can say what that was last Tuesday.
  • Letting every developer push release tags. Restrict who can.

Safeguard's policy gates can evaluate the image behind a tag at pull request and release time, so the check follows the digest.

Quick check

Can a Docker tag contain a plus sign?

No. The permitted characters are letters, digits, underscore, period and hyphen, and the tag cannot start with a period or hyphen.

Should production deploy by tag or digest?

By digest. A tag can be moved unless the registry forbids it, while a digest names exact content.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.