A distroless image is a minimal Docker image that contains only the application and its runtime dependencies, without any operating system shell or package manager.
Click to reveal answer
beginner
Why are distroless images considered more secure?
Because they exclude shells and package managers, reducing the attack surface and limiting what an attacker can do if they gain access to the container.
Click to reveal answer
beginner
How do distroless images affect the size of Docker containers?
Distroless images are smaller because they remove unnecessary OS components, which helps reduce the container size and speeds up deployment.
Click to reveal answer
beginner
Can you run shell commands inside a distroless container?
No, distroless images do not include a shell, so you cannot run shell commands inside the container.
Click to reveal answer
beginner
What is a common use case for distroless images?
They are commonly used in production environments where security and small image size are important, especially for microservices and cloud-native applications.
Click to reveal answer
What is missing from a distroless Docker image compared to a traditional base image?
AOperating system shell and package manager
BApplication runtime
CNetwork support
DContainer runtime
✗ Incorrect
Distroless images remove the OS shell and package manager to reduce size and improve security.
Why might you choose a distroless image for your container?
ATo include development tools
BTo have a full Linux environment inside the container
CTo enable easy debugging with shell access
DTo reduce image size and improve security
✗ Incorrect
Distroless images focus on minimal size and security, not on providing a full OS or debugging tools.
Which of the following is true about distroless images?
AThey include a bash shell by default
BThey are larger than traditional images
CThey contain only the app and its runtime dependencies
DThey are only used for development
✗ Incorrect
Distroless images contain only the application and necessary runtime dependencies.
If you need to debug inside a container, what is a limitation of distroless images?
AThey lack a shell to run commands
BThey cannot run applications
CThey do not support networking
DThey are read-only
✗ Incorrect
Distroless images do not include a shell, so you cannot run interactive commands inside.
Which scenario best fits using a distroless image?
ADeveloping and testing new features interactively
BRunning a secure, lightweight production service
CBuilding a full Linux desktop environment
DRunning containers that require package installation at runtime
✗ Incorrect
Distroless images are ideal for secure, lightweight production deployments.
Explain what a distroless image is and why it is useful in Docker container deployments.
Think about what is removed from the image and the benefits it brings.
You got /5 concepts.
Describe the trade-offs when using distroless images compared to traditional Docker base images.
Consider what you gain and what you lose.
You got /5 concepts.
Practice
(1/5)
1. What is the main advantage of using distroless images in Docker containers?
easy
A. They keep containers small and secure by including only necessary files
B. They include a full Linux distribution for easier debugging
C. They come with built-in shells and package managers
D. They automatically update the application inside the container
Solution
Step 1: Understand what distroless images contain
Distroless images include only the application and its runtime dependencies, excluding shells and package managers.
Step 2: Identify the benefit of minimal content
By including only what is needed, the image size is smaller and the attack surface is reduced, improving security.
Final Answer:
They keep containers small and secure by including only necessary files -> Option A
Quick Check:
Minimal content = Small and secure [OK]
Hint: Distroless means minimal, no shells or extras included [OK]
Common Mistakes:
Thinking distroless images have shells for debugging
Assuming they include full Linux distributions
Believing they auto-update applications
2. Which of the following is the correct way to specify a distroless base image in a Dockerfile?
easy
A. FROM ubuntu:latest
B. FROM alpine:3.15
C. FROM gcr.io/distroless/base
D. FROM node:distroless
Solution
Step 1: Identify official distroless image naming
Distroless images are hosted at gcr.io/distroless with names like 'base', 'static', or language-specific tags.
Step 2: Compare options to distroless naming
Only 'gcr.io/distroless/base' matches the official distroless image naming convention.
Final Answer:
FROM gcr.io/distroless/base -> Option C
Quick Check:
Official distroless images start with gcr.io/distroless [OK]
Hint: Distroless images start with gcr.io/distroless prefix [OK]
Common Mistakes:
Using common Linux distros like ubuntu or alpine as distroless
Assuming 'node:distroless' is a valid tag
Confusing distroless with minimal Linux images
3. Given this Dockerfile snippet using a distroless image:
FROM gcr.io/distroless/base
COPY app /app
CMD ["/app"]
What will happen if you try to run docker run and then execute sh inside the container?
medium
A. You will get a shell prompt because distroless images include shells
B. You will get an error saying 'sh: not found' because no shell is included
C. The container will crash immediately on start
D. The container will open a shell automatically
Solution
Step 1: Understand distroless image contents
Distroless images do not include shells or package managers, only the app and runtime.
5. You want to build a secure production Docker image for a Go app using distroless. Which multi-stage Dockerfile snippet correctly builds and runs the app with minimal image size and attack surface?
hard
A. FROM golang:1.20 AS build
WORKDIR /app
COPY . .
RUN go build -o app
FROM gcr.io/distroless/base
COPY --from=build /app/app /app
CMD ["/app"]
B. FROM golang:1.20
WORKDIR /app
COPY . .
RUN go build -o app
CMD ["./app"]
C. FROM alpine:latest
WORKDIR /app
COPY . .
RUN go build -o app
CMD ["./app"]
D. FROM gcr.io/distroless/base
COPY app /app
RUN go build -o app
CMD ["/app"]
Solution
Step 1: Understand multi-stage build for distroless
Build the Go app in a full image with build tools, then copy the binary into a minimal distroless image.
Step 2: Analyze options for correct multi-stage usage
Only FROM golang:1.20 AS build
WORKDIR /app
COPY . .
RUN go build -o app
FROM gcr.io/distroless/base
COPY --from=build /app/app /app
CMD ["/app"] uses golang image to build, then copies binary into distroless base image for runtime, minimizing size and attack surface.
Final Answer:
FROM golang:1.20 AS build
WORKDIR /app
COPY . .
RUN go build -o app
FROM gcr.io/distroless/base
COPY --from=build /app/app /app
CMD ["/app"] -> Option A
Quick Check:
Build in full image, run in distroless = secure minimal image [OK]
Hint: Build in full image, copy binary to distroless for runtime [OK]
Common Mistakes:
Trying to build inside distroless image (no build tools)
Using single-stage build with full image (larger size)
Using alpine without distroless for production
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.