0
0
Dockerdevops~20 mins

Choosing small base images (alpine, slim) in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Small Image Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why choose Alpine as a base image?

Which of the following is the main reason to choose Alpine Linux as a Docker base image?

AIt includes all development tools by default for easy compiling.
BIt is the official image for all programming languages.
CIt has a very small size, reducing image bloat and download time.
DIt automatically updates packages to the latest versions.
Attempts:
2 left
💡 Hint

Think about what helps reduce the size of Docker images.

💻 Command Output
intermediate
2:00remaining
Output size difference between base images

Given the following Dockerfiles, which option correctly shows the approximate size difference when building the images?

FROM python:3.12-alpine
RUN python --version
---
FROM python:3.12-slim
RUN python --version
ABoth images are about 200MB in size.
BAlpine image is about 50MB, Slim image is about 120MB.
CAlpine image is about 300MB, Slim image is about 100MB.
DAlpine image is about 120MB, Slim image is about 50MB.
Attempts:
2 left
💡 Hint

Alpine is known for being smaller than slim.

Configuration
advanced
2:00remaining
Choosing the right base image for a Node.js app

You want to build a Node.js app Docker image that is as small as possible but still supports native modules compilation. Which base image should you choose?

Anode:20-slim
Bnode:20-alpine
Cnode:20-buster
Dnode:20-windows
Attempts:
2 left
💡 Hint

Alpine uses musl libc which can cause issues with native modules.

Troubleshoot
advanced
2:00remaining
Troubleshooting missing libraries in Alpine image

You built a Docker image using python:3.12-alpine and your app crashes with an error about missing libc. What is the most likely cause?

AAlpine uses musl libc instead of glibc, causing compatibility issues.
BThe image is missing Python entirely.
CThe Dockerfile did not specify a working directory.
DThe app requires Windows libraries not available on Alpine.
Attempts:
2 left
💡 Hint

Think about the difference between musl and glibc.

Best Practice
expert
2:30remaining
Optimizing multi-stage Docker builds with small base images

In a multi-stage Docker build, which approach best uses small base images to minimize final image size while ensuring build tools are available?

AUse a Windows base image for the build stage and Alpine for the final stage.
BUse Alpine in both build and final stages to keep everything small.
CUse the same large base image for both stages to avoid compatibility issues.
DUse a full build image (like debian) in the first stage, then copy only the final app files into a minimal Alpine image in the final stage.
Attempts:
2 left
💡 Hint

Think about separating build dependencies from runtime environment.