Intermediate Docker & Containers
Q44 / 100

Why is the ordering of instructions in a Dockerfile important for build performance?

Correct! Well done.

Incorrect.

The correct answer is B) Docker caches layers and invalidates the cache for a layer and all subsequent layers once a change is detected, so placing rarely-changing steps (dependency installs) before frequently-changing ones (copying source code) maximizes cache reuse

B

Correct Answer

Docker caches layers and invalidates the cache for a layer and all subsequent layers once a change is detected, so placing rarely-changing steps (dependency installs) before frequently-changing ones (copying source code) maximizes cache reuse

Explanation

Since a cache miss on one layer invalidates all subsequent layers, placing stable steps (installing dependencies) early and frequently-changing steps (copying app code) later avoids unnecessary re-execution of expensive steps.

Progress
44/100