Docker interview question · Most asked

How should you tag Docker images, and why is 'latest' a problem?

Summary

Tag images with immutable, traceable identifiers such as the Git commit SHA (and optionally a semantic version), and deploy by those tags or by digest. latest is just a default tag name, not 'the newest version': it moves, so different hosts can run different code under the same tag, rollbacks are unclear, and caches may serve stale images.

Longer Answer

Good practice: org/app:1.4.2 plus org/app:git-3f9c2ab; enable tag immutability in the registry (ECR, Artifact Registry) so a tag can never be overwritten; deploy by digest (@sha256:...) for full reproducibility; and use latest (if at all) only for local convenience. Record which tag runs in each environment for audits and rollbacks.

Key Points

  • Immutable tags: commit SHA, semver.
  • 'latest' moves and is ambiguous.
  • Registry tag immutability.
  • Deploy by digest for reproducibility.

More most-asked Docker questions

← All Docker questions