Bird
0
0

Given this Dockerfile:

medium📝 Command Output Q13 of 15
Docker - Image Optimization
Given this Dockerfile:
FROM alpine
RUN echo 'Hello' > /file1
RUN echo 'World' > /file2

What is the main difference in the image size when built with and without --squash?
AThe image with --squash is smaller because layers are combined
BThe image with --squash is larger because it adds extra metadata
CBoth images have the same size because layers do not affect size
DThe image without --squash is smaller because layers are cached
Step-by-Step Solution
Solution:
  1. Step 1: Understand how layers affect image size

    Each RUN command creates a new layer, adding to the total image size.
  2. Step 2: Effect of --squash on layers

    Using --squash merges layers, removing intermediate data and reducing size.
  3. Final Answer:

    The image with --squash is smaller because layers are combined -> Option A
  4. Quick Check:

    Squash reduces size by merging layers [OK]
Quick Trick: Squash merges layers, reducing image size [OK]
Common Mistakes:
  • Thinking squashing adds metadata and increases size
  • Believing layers do not affect image size
  • Confusing caching with squashing effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes