Bird
0
0

You want to reduce image size by removing build tools after compiling your app. Which Dockerfile pattern achieves this best?

hard📝 Workflow Q8 of 15
Docker - Image Optimization
You want to reduce image size by removing build tools after compiling your app. Which Dockerfile pattern achieves this best?
AUse a single stage and delete build tools in a separate RUN
BInstall build tools in the final image and remove manually
CKeep build tools but compress the image later
DUse multi-stage builds to separate build and runtime
Step-by-Step Solution
Solution:
  1. Step 1: Understand multi-stage builds

    Multi-stage builds allow compiling in one stage and copying only needed files to final image.
  2. Step 2: Benefits of multi-stage

    This avoids including build tools in the final image, reducing size significantly.
  3. Final Answer:

    Multi-stage builds separate build and runtime, minimizing final image size. -> Option D
  4. Quick Check:

    Multi-stage builds reduce final image size [OK]
Quick Trick: Use multi-stage builds to exclude build tools from final image [OK]
Common Mistakes:
  • Removing tools manually leaves layers
  • Compressing image doesn't remove files
  • Single stage keeps build tools

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes