Bird
0
0

You want to optimize a Docker image for a Python app. Which combination of steps best reduces image size and speeds deployment?

hard📝 Best Practice Q15 of 15
Docker - Image Optimization
You want to optimize a Docker image for a Python app. Which combination of steps best reduces image size and speeds deployment?
AUse a slim base image, combine RUN commands, and clean package caches
BUse a full OS base image and install all development tools
CCopy all files first, then install packages separately
DAvoid cleaning caches to speed up builds
Step-by-Step Solution
Solution:
  1. Step 1: Choose a slim base image

    Slim images have fewer packages, reducing size.
  2. Step 2: Combine RUN commands and clean caches

    Combining commands reduces layers; cleaning caches removes unnecessary files.
  3. Final Answer:

    Use a slim base image, combine RUN commands, and clean package caches -> Option A
  4. Quick Check:

    Combine steps + slim base = optimized image [OK]
Quick Trick: Combine commands and clean caches for smaller images [OK]
Common Mistakes:
  • Using full OS base images unnecessarily
  • Not cleaning caches after installs
  • Copying files before installing dependencies

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes