Interview Prep/Docker/Multi-stage builds, cache, tags and registries

How do you keep a `latest` tag but still know which build it points to?

BeginnerScenarioMulti-stage builds, cache, tags and registries
Answer

Situation read → Operators need traceability.

What I'd do → Add OCI labels at build time:

LABEL org.opencontainers.image.revision=$GIT_SHA \
      org.opencontainers.image.source=https://github.com/acme/app \
      org.opencontainers.image.created=$BUILD_DATE

Then docker inspect -f '{{json .Config.Labels}}' app:latest. Or use docker/metadata-action to generate them.

Why → Labels travel with the image.

Interview tip → The org.opencontainers.image.* namespace is the standard.

All Docker questions Roadmap: Docker & containers

More on Multi-stage builds, cache, tags and registries