Skip to content
tezvyn:

How do you version Docker images: Git SHA or SemVer?

Source: oneuptime.comMediumHow cards are made

How do you version Docker images: Git SHA or SemVer?

Your grasp of immutable artifacts and traceability versus human-readable releases. Tag every build with Git SHA for immutability, then apply SemVer aliases only on promoted images. Treating floating tags like latest or v1 as safe production targets.

What's really being asked

This question evaluates whether you understand that a Docker tag is a mutable pointer, not a guarantee, and that production deployments require immutable, traceable artifacts. The interviewer wants to see if you distinguish between build-time identity and release-time identity. They also care whether you recognize that Git SHA and SemVer are not mutually exclusive but serve different stages of the supply chain.

The full answer

First, state that every CI build should produce an image tagged with the full Git commit SHA. This creates an immutable, one-to-one mapping between source code and artifact that eliminates ambiguity during debugging. Second, explain that Semantic Versioning should be applied only to images that pass promotion gates and are declared release-worthy. SemVer tags like v1.2.3 are human-readable and communicate breaking-change contracts, but they are floating aliases that can be moved. Third, describe a hybrid workflow where the SHA tag is the canonical reference stored in deployment manifests and Helm values, while SemVer tags are convenience labels for changelog consumers and rollback menus. Fourth, mention that rolling tags such as v1 or v1.2 are acceptable for non-production consumers who want automatic patches, but production manifests should pin the exact SHA or the full SemVer triple to prevent drift.

The mistakes people make

A major red flag is recommending latest as a production tag because it is non-deterministic and makes rollbacks nearly impossible. Another mistake is treating SemVer as immutable. Candidates who say v1 always points to the same image misunderstand that tags are mutable pointers in Docker. Similarly, using only SemVer without SHA tags loses the direct source-to-artifact link, forcing teams to hunt through build logs to map a version back to code. Finally, suggesting build-number tags alone misses the traceability to source control that Git SHA provides.

What usually comes next

The interviewer may ask how you prevent tag mutation in production, so be ready to discuss registry immutability policies or admission controllers that reject unpinned images. They might also ask how to handle hotfix branches, which is a chance to explain tagging those builds with the branch name plus SHA and later re-tagging with a patched SemVer. Another follow-up is how to garbage-collect old images without breaking rollback. The answer is to keep every SHA for a retention window and only delete untagged intermediates.

A concrete example

Suppose a pipeline builds commit abc1234. The CI system tags the image myapp:abc1234 and pushes it. After passing integration tests, the image is promoted and receives myapp:v1.2.3, myapp:v1.2, and myapp:v1. The Kubernetes production manifest references myapp:abc1234 directly, while the release notes point consumers to myapp:v1.2.3. If a critical bug is found, the team can instantly roll back to the previous SHA because the deployment history contains the immutable reference, not a floating tag.

Interview question

In a hybrid Docker tagging strategy, what distinguishes the role of a Git SHA tag from a SemVer tag at production deployment time?

  • a.The Git SHA tag is safe to use as a rolling production target, while SemVer tags must be pinned to prevent drift.
  • b.The Git SHA tag is applied only after promotion gates pass, whereas SemVer tags are generated automatically on every CI build.
  • c.The Git SHA tag serves as a mutable alias for changelog consumers, while SemVer acts as the immutable canonical reference.
  • d.The Git SHA tag provides an immutable source-to-artifact mapping used in deployment manifests, while SemVer offers human-readable labels for promoted releases.Correct
Why?

Git SHA tags are immutable pointers created on every build to provide exact source-to-artifact traceability in manifests, while SemVer tags are human-readable aliases added only to promoted releases. Distractor C reverses this workflow: SHA tags are generated automatically per build, and SemVer is reserved for promoted images.

Just read this? Test yourself on what you have been reading.

Read the original → oneuptime.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on docker — each one lists the topics its interview covers.

See open roles