0
0
Dockerdevops~20 mins

Squashing layers in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Layer Squasher Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why squash Docker image layers?

What is the main benefit of squashing layers in a Docker image?

AIt automatically updates the base image to the latest version.
BIt increases build speed by caching all layers separately.
CIt reduces the final image size by combining multiple layers into one.
DIt splits the image into multiple smaller images for easier distribution.
Attempts:
2 left
💡 Hint

Think about how layers add up in size and how combining them affects the image.

💻 Command Output
intermediate
1:30remaining
Output of Docker build with --squash

What output will you see when running docker build --squash -t myapp . if the Docker daemon supports squashing?

ASuccessfully built <image_id> with all layers squashed into one.
BError: unknown flag: --squash
CWarning: --squash ignored, using default layering.
DBuild completed but layers remain separate.
Attempts:
2 left
💡 Hint

Consider if the Docker daemon supports the experimental feature for squashing.

Configuration
advanced
2:00remaining
Enable Docker experimental features for squashing

Which configuration change enables Docker's experimental features to allow layer squashing?

ARun Docker with --enable-experimental flag every time.
BSet environment variable DOCKER_SQUASH=enabled before building.
CInstall a separate Docker plugin for squashing layers.
DAdd "experimental": true to the daemon.json file and restart Docker.
Attempts:
2 left
💡 Hint

Think about Docker daemon configuration files and how to enable experimental features globally.

Troubleshoot
advanced
2:00remaining
Why does --squash flag cause an error?

You run docker build --squash -t myapp . but get the error: "unknown flag: --squash". What is the most likely cause?

ADocker daemon experimental features are not enabled.
BThe Dockerfile syntax is incorrect.
CThe build context directory is missing.
DThe Docker client version is too new for this flag.
Attempts:
2 left
💡 Hint

Check if the Docker daemon supports the feature you are trying to use.

🔀 Workflow
expert
2:30remaining
Best workflow to minimize image size with squashing

Which workflow best minimizes Docker image size using squashing while keeping build cache benefits?

ASquash all layers in every build to one layer immediately.
BUse multi-stage builds and squash only the final stage layers.
CBuild without squashing, then manually delete intermediate images.
DUse a single RUN command for all steps without squashing.
Attempts:
2 left
💡 Hint

Consider how multi-stage builds and squashing can work together to optimize size and caching.