0
0
Dockerdevops~20 mins

Image layers concept in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Docker Layers Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Docker image layers

Which statement best describes Docker image layers?

ALayers are stacked read-only filesystems that build the final image.
BLayers are temporary and deleted after container creation.
CEach layer is a full copy of the entire image filesystem.
DLayers are only used for container runtime, not image building.
Attempts:
2 left
💡 Hint

Think about how Docker reuses parts of images to save space.

💻 Command Output
intermediate
2:00remaining
Inspecting image layers with Docker CLI

What is the output of the command docker history alpine?

Docker
docker history alpine
AA list showing image layers with size, creation time, and commands used.
BA list of running containers based on alpine image.
CThe full Dockerfile used to build alpine image.
DAn error stating 'alpine' image not found.
Attempts:
2 left
💡 Hint

Try to recall what docker history shows about images.

🔀 Workflow
advanced
2:30remaining
Optimizing Dockerfile to reduce image layers

You want to reduce the number of layers in your Docker image. Which Dockerfile snippet achieves this best?

Docker
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
ARUN apt-get update; apt-get install -y curl; rm -rf /var/lib/apt/lists/*
B
RUN apt-get update
RUN apt-get install -y curl
RUN rm -rf /var/lib/apt/lists/*
CRUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
D
RUN apt-get update && apt-get install -y curl
RUN rm -rf /var/lib/apt/lists/*
Attempts:
2 left
💡 Hint

Think about how Docker creates a new layer for each RUN instruction.

Troubleshoot
advanced
2:30remaining
Diagnosing unexpected large Docker image size

Your Docker image is unexpectedly large. Which cause is most likely related to image layers?

AYou used COPY instead of ADD for files.
BYou used ENV variables in the Dockerfile.
CYou did not specify a base image in the Dockerfile.
DYou used multiple RUN commands that add temporary files without cleanup.
Attempts:
2 left
💡 Hint

Think about how layers keep all changes, even deleted files if not cleaned properly.

Best Practice
expert
3:00remaining
Choosing the best practice for layer caching in Docker builds

Which Dockerfile practice best leverages layer caching to speed up rebuilds?

APlace frequently changing commands at the top of the Dockerfile.
BOrder commands from least to most frequently changing to maximize cache reuse.
CCombine all commands into one RUN instruction regardless of change frequency.
DAvoid using COPY or ADD commands to prevent cache invalidation.
Attempts:
2 left
💡 Hint

Think about how Docker caches layers and when cache is invalidated.