Bird
0
0

After identifying a Docker image layer with many unnecessary files using dive, what is the best practice to reduce image size?

hard📝 Workflow Q8 of 15
Docker - Image Optimization
After identifying a Docker image layer with many unnecessary files using dive, what is the best practice to reduce image size?
AIncrease the base image size to accommodate extra files
BIgnore the layer since it does not affect runtime
CAdd more layers to separate files for better caching
DModify the Dockerfile to exclude or clean up those files in that layer
Step-by-Step Solution
Solution:
  1. Step 1: Analyze layer contents

    Unnecessary files increase image size and should be removed or excluded.
  2. Step 2: Adjust Dockerfile

    Modify the Dockerfile commands to avoid adding those files or clean them up in the same layer.
  3. Final Answer:

    Modify the Dockerfile to exclude or clean up those files in that layer -> Option D
  4. Quick Check:

    Reducing files in layers reduces image size [OK]
Quick Trick: Clean layers via Dockerfile edits to shrink image [OK]
Common Mistakes:
  • Ignoring unnecessary files thinking they don't matter
  • Adding more layers without cleanup
  • Increasing base image size unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes