Problem Statement
What common mistakes in Dockerfile layering can cause longer builds or larger images?
Explanation
Common mistakes include placing frequently changed instructions (like COPY . .) before less-frequently changed ones, triggering rebuilding of the same layers repeatedly; using heavy base images unnecessarily; leaving build tools and dependencies in runtime images; not combining RUN commands; and not using multi-stage builds. Optimising layering order, cleaning up caches and separating build/runtime environments avoids these issues.
Practice Sets
This question appears in the following practice sets:
