Bird
0
0

In a CI pipeline, you want to maximize Docker layer caching efficiency across multiple builds. Which approach is best?

hard📝 Workflow Q15 of 15
Docker - in CI/CD
In a CI pipeline, you want to maximize Docker layer caching efficiency across multiple builds. Which approach is best?
AUse <code>--no-cache</code> to force fresh builds every time
BBuild images locally on the CI server without pushing
CPush the built image to a registry and use <code>--cache-from</code> with that image in subsequent builds
DDelete all images after each build to save space
Step-by-Step Solution
Solution:
  1. Step 1: Understand persistent caching in CI

    To reuse cache between builds, the cache must be stored persistently, usually by pushing images to a registry.
  2. Step 2: Use cache-from with pushed images

    Using --cache-from with the pushed image allows Docker to reuse layers from previous builds, speeding up future builds.
  3. Final Answer:

    Push the built image to a registry and use --cache-from with that image in subsequent builds -> Option C
  4. Quick Check:

    Persistent cache storage + --cache-from = efficient caching [OK]
Quick Trick: Push images and use --cache-from for persistent caching [OK]
Common Mistakes:
  • Using --no-cache disables caching
  • Deleting images removes cache
  • Building locally without pushing loses cache between runs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes