A base image is the starting point for building a Docker image. It contains the basic operating system or runtime environment on which you add your application and dependencies.
Click to reveal answer
beginner
Why choose small base images like Alpine or Slim?
Small base images reduce the final image size, which means faster downloads, less storage use, and quicker startup times for containers.
Click to reveal answer
beginner
What is Alpine Linux in the context of Docker images?
Alpine Linux is a very small, security-focused Linux distribution often used as a minimal base image in Docker to keep images lightweight.
Click to reveal answer
intermediate
What does the 'slim' tag mean in Docker base images?
The 'slim' tag indicates a smaller version of a base image that removes unnecessary files and tools but keeps compatibility with most applications.
Click to reveal answer
intermediate
What is a trade-off when using Alpine as a base image?
Alpine images are very small but may require extra work to install some libraries or tools because it uses a different package manager and libc implementation.
Click to reveal answer
Which of these is a benefit of using Alpine as a Docker base image?
ASmaller image size
BIncludes all development tools by default
CUses the same package manager as Ubuntu
DAlways the fastest runtime
✗ Incorrect
Alpine is known for its small size, which helps reduce image size and download time.
What does the 'slim' tag usually indicate in Docker images?
AA larger image with extra tools
BAn image with debugging enabled
CAn image based on Alpine Linux
DA smaller image with unnecessary files removed
✗ Incorrect
The 'slim' tag means the image is smaller by removing unnecessary files but keeps compatibility.
What is a common challenge when using Alpine images?
AThey are very large
BThey use a different libc and package manager
CThey do not support containers
DThey come with too many pre-installed tools
✗ Incorrect
Alpine uses musl libc and apk package manager, which can cause compatibility issues.
Why might you choose a 'slim' image over Alpine?
AFor better compatibility with common libraries
BBecause it is always smaller than Alpine
CBecause it uses musl libc
DBecause it has no package manager
✗ Incorrect
'Slim' images keep compatibility with common libraries while reducing size.
What is the main reason to use small base images in Docker?
ATo increase container startup time
BTo avoid using any package manager
CTo reduce image size and speed up deployment
DTo include more software by default
✗ Incorrect
Smaller images reduce download time and storage, making deployments faster.
Explain the benefits and trade-offs of using Alpine as a Docker base image.
Think about size, security, and compatibility.
You got /5 concepts.
Describe what the 'slim' tag means for Docker base images and when you might choose it.
Consider size and compatibility trade-offs.
You got /4 concepts.
Practice
(1/5)
1. Why do developers often choose small base images like alpine or slim when building Docker containers?
easy
A. To reduce image size and speed up container startup
B. To increase the number of installed packages by default
C. To make the container run only on Windows systems
D. To disable networking inside the container
Solution
Step 1: Understand the purpose of small base images
Small base images like alpine or slim are designed to be lightweight, which means they have fewer files and smaller size.
Step 2: Connect size to performance
Smaller images download faster and start containers quicker, improving efficiency.
Final Answer:
To reduce image size and speed up container startup -> Option A
Quick Check:
Small base images = smaller size and faster startup [OK]
Hint: Small images mean faster downloads and startups [OK]
Common Mistakes:
Thinking small images have more packages by default
Assuming small images restrict OS compatibility
Believing small images disable networking
2. Which of the following is the correct way to specify the Alpine base image in a Dockerfile?
easy
A. IMAGE alpine:latest
B. FROM alpine/latest
C. BASE alpine:latest
D. FROM alpine:latest
Solution
Step 1: Recall Dockerfile syntax for base images
The correct keyword to specify a base image is FROM, followed by the image name and tag separated by a colon.
Step 2: Check each option
FROM alpine:latest uses FROM alpine:latest, which is correct syntax. Options A, B, and C use incorrect keywords or separators.
Final Answer:
FROM alpine:latest -> Option D
Quick Check:
Base image syntax = FROM image:tag [OK]
Hint: Use FROM keyword with colon-separated tag [OK]
Common Mistakes:
Using slash instead of colon between image and tag
Using BASE or IMAGE instead of FROM
Omitting the tag separator
3. Given this Dockerfile snippet:
FROM python:3.12-alpine
RUN python --version
What will be the expected output when building this image?
medium
A. Python 3.12.x (Alpine variant)
B. Error: python command not found
C. Python 2.7.x default version
D. No output, build fails silently
Solution
Step 1: Identify the base image and its contents
The base image is python:3.12-alpine, which includes Python 3.12 installed on Alpine Linux.
Step 2: Understand the RUN command effect
The command python --version will print the Python version installed in the image during build.
Final Answer:
Python 3.12.x (Alpine variant) -> Option A
Quick Check:
python:3.12-alpine includes Python 3.12 [OK]
Hint: Tagged python alpine images include Python by default [OK]
Common Mistakes:
Assuming python is missing in alpine variant
Confusing Python 2 with Python 3
Expecting silent build without output
4. You wrote this Dockerfile:
FROM node:18-slim
RUN apk add curl
But the build fails with "apk: command not found". What is the problem?
medium
A. You must install curl before FROM statement
B. Node 18-slim image does not support RUN commands
C. The slim image uses apt, not apk, so apk command is missing
D. The command should be RUN apt-get add curl
Solution
Step 1: Identify the base image OS
The node:18-slim image is based on Debian, which uses apt package manager, not apk.
Step 2: Understand the error cause
Using apk (Alpine package manager) on Debian-based image causes "command not found" error.
Final Answer:
The slim image uses apt, not apk, so apk command is missing -> Option C
Quick Check:
Debian slim uses apt, not apk [OK]
Hint: Use apt on slim (Debian), apk on alpine [OK]
Common Mistakes:
Trying apk on Debian-based images
Placing RUN commands before FROM
Using unsupported RUN syntax
5. You want a small Docker image for a Python app but need some common Linux tools like curl and bash. Which base image choice balances size and compatibility best?
hard
A. python:3.12-alpine (smallest but may need extra setup)
B. python:3.12-slim (slightly larger but includes common tools)
C. python:3.12-full (largest, includes all tools by default)
D. python:3.12-minimal (no tools, smallest size)
Solution
Step 1: Compare alpine and slim images
Alpine is smallest but often lacks common tools, requiring manual installs. Slim is bigger but includes many common Linux utilities.
Step 2: Match needs to image choice
Since you need tools like curl and bash, slim is a better balance of size and compatibility than alpine.
Final Answer:
python:3.12-slim (slightly larger but includes common tools) -> Option B
Quick Check:
Slim balances size and tools better than alpine [OK]
Hint: Choose slim for tools, alpine for smallest size [OK]
Common Mistakes:
Picking alpine without adding needed tools
Assuming minimal includes tools
Choosing full image without size concern
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.