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

A multi-stage build copies from `--from=build` but the final image is still huge. Why?

IntermediateScenarioMulti-stage builds, cache, tags and registries
Answer

Situation read → Probably copying a whole directory (COPY --from=build /src /app) including node_modules dev deps or source, or the final stage is built FROM build.

What I'd do →

  1. docker history app to find the heavy layer.
  2. Copy only artifacts (/src/dist, the binary).
  3. Install prod-only deps in the final stage or prune (npm prune --omit=dev).
  4. Verify with dive.

Why → Multi-stage only helps if the last stage starts from a clean base.

Interview tip → Check that the last FROM is the slim runtime image.

All Docker questions Roadmap: Docker & containers

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