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

You need to run integration tests against the exact image you will ship.

IntermediateScenarioMulti-stage builds, cache, tags and registries
Answer

Situation read → Testing a different build than the one released defeats the purpose.

What I'd do →

  1. Build once and load: docker buildx build --load -t app:$SHA ..
  2. Start dependencies with Compose, run tests against app:$SHA (Testcontainers or docker compose up --wait).
  3. Push that same digest only if tests pass.

Why → Promote the artefact, not the source.

Interview tip → docker compose up --wait blocks until health checks pass.

All Docker questions Roadmap: Docker & containers

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