0
0
Dockerdevops~20 mins

Distroless images concept in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Distroless Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use Distroless images in Docker?

Which of the following is the main advantage of using Distroless images for Docker containers?

AThey include a full operating system for easier debugging inside the container
BThey automatically update the container with the latest OS patches
CThey reduce image size and attack surface by excluding package managers and shells
DThey allow running containers without specifying a base image
Attempts:
2 left
💡 Hint

Think about what is removed from Distroless images compared to traditional base images.

💻 Command Output
intermediate
2:00remaining
Output of running a Distroless image without shell

What will happen if you try to run docker run -it distroless/base and then try to execute bash inside the container?

AYou get an error: 'bash: command not found'
BThe container exits immediately because no shell is available
CThe container restarts automatically
DYou get a shell prompt and can run bash commands
Attempts:
2 left
💡 Hint

Distroless images do not include shells like bash.

Configuration
advanced
3:00remaining
Dockerfile using Distroless image for a Go app

Which Dockerfile snippet correctly builds a Go application and uses a Distroless image for the final container?

A
FROM golang:1.20 AS builder
WORKDIR /app
COPY . .
RUN go build -o myapp
FROM gcr.io/distroless/base
COPY --from=builder /app/myapp /
CMD ["/myapp"]
B
FROM golang:1.20
WORKDIR /app
COPY . .
RUN go build -o myapp
FROM ubuntu
COPY --from=builder /app/myapp /
CMD ["/myapp"]
C
FROM alpine
WORKDIR /app
COPY . .
RUN go build -o myapp
CMD ["/myapp"]
D
FROM gcr.io/distroless/base
WORKDIR /app
COPY . .
RUN go build -o myapp
CMD ["/myapp"]
Attempts:
2 left
💡 Hint

Look for a multi-stage build that compiles the app first, then copies the binary into a Distroless image.

Troubleshoot
advanced
2:30remaining
Why does a Distroless container fail to start with 'no such file or directory'?

You built a container using a Distroless image but it fails to start with the error: no such file or directory. What is the most likely cause?

AThe container lacks a shell to run the binary
BThe binary is missing executable permissions
CThe Dockerfile is missing the CMD instruction
DThe binary depends on shared libraries not included in the Distroless image
Attempts:
2 left
💡 Hint

Distroless images include only minimal runtime dependencies.

Best Practice
expert
3:00remaining
Best practice for debugging Distroless containers

Since Distroless containers lack shells and debugging tools, what is the best practice to debug issues inside such containers?

AAdd a shell and debugging tools to the Distroless image
BUse multi-stage builds to create a debug image with tools and run it instead
CRun the container with <code>docker exec -it</code> to get shell access
DRestart the container with verbose logging enabled
Attempts:
2 left
💡 Hint

Think about how to keep the final image minimal but still debug when needed.