advancedTop 100 Interview Questions

Why is rebuilding the entire fat jar layer on every code change, even with multi-stage builds, still a cache-efficiency problem?

If the Dockerfile copies the whole fat jar as a single COPY instruction, any code change invalidates that entire layer regardless of multi-stage build usage — the fix is using Spring Boot's layered jar feature to split dependencies (rarely change) from application classes (change often) into separate COPY instructions, so only the small, frequently-changing layer needs to rebuild.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to What are the three biggest levers for improving Docker build performance?← Back to all Docker questions