Bird
0
0

Given this Dockerfile:

medium📝 Command Output Q4 of 15
Docker - Image Optimization
Given this Dockerfile:
FROM ubuntu
RUN apt-get update
RUN apt-get install -y curl
RUN echo 'Done'

What is the effect on the image size when built with docker build --squash compared to a normal build?
AThe image size will be smaller because layers are combined
BThe image size will be larger due to extra metadata
CThe image size remains the same
DThe build will fail due to unsupported command
Step-by-Step Solution
Solution:
  1. Step 1: Understand layer creation in Dockerfile

    Each RUN command creates a new layer increasing image size.
  2. Step 2: Effect of --squash on layers

    Squashing merges these layers into one, reducing overall image size.
  3. Final Answer:

    The image size will be smaller because layers are combined -> Option A
  4. Quick Check:

    Squash reduces image size by merging layers [OK]
Quick Trick: Squash merges layers, shrinking image size [OK]
Common Mistakes:
  • Assuming squashing adds metadata increasing size
  • Believing image size stays unchanged
  • Thinking build fails with --squash

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes