advancedScenario-Based & System Design Questions
A multi-stage Docker build's final image is still much larger than expected despite using multi-stage builds correctly.
Common causes: the final stage's base image itself is large (a full distro instead of Alpine/slim/distroless), unnecessary files were still copied from the builder stage (overly broad `COPY --from=builder /app /app` instead of copying only the specific built artifact), or build caches/temp files were generated inside the final stage itself rather than only in the builder stage. Inspect with `docker history` and tools like `dive` to identify which layer/instruction added the unexpected size.
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full DevOps Mastery library.
A multi-stage Docker build's final image is still much larger than expected despite using multi-stage builds correctly.