Bird
0
0

Which Dockerfile instruction helps reduce image size by removing unnecessary files?

easy📝 Syntax Q12 of 15
Docker - Image Optimization
Which Dockerfile instruction helps reduce image size by removing unnecessary files?
ARUN apt-get update
BRUN rm -rf /var/lib/apt/lists/*
CCOPY . /app
DEXPOSE 80
Step-by-Step Solution
Solution:
  1. Step 1: Identify cleanup commands

    Removing package lists after installation reduces image size.
  2. Step 2: Understand the command effect

    RUN rm -rf /var/lib/apt/lists/* deletes cached package files, freeing space.
  3. Final Answer:

    RUN rm -rf /var/lib/apt/lists/* -> Option B
  4. Quick Check:

    Cleanup commands reduce image size [OK]
Quick Trick: Remove cache files after install to shrink image [OK]
Common Mistakes:
  • Using COPY to reduce size (it adds files)
  • Exposing ports does not affect size
  • Forgetting to clean package caches

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes