tezvyn:

Distroless images: benefits and trade-offs

AI-drafted, machine-checkedSource: interviewadvanced
WHAT IT TESTS

minimal base image strategy.

OUTLINE

distroless ships only the app and runtime deps, no shell or package manager; smaller and a smaller attack surface than Alpine; trade-off is harder debugging with no shell.

WHAT THIS TESTS It checks whether you understand attack-surface reduction at the base-image level and can reason about the operational cost it imposes.

A GOOD ANSWER COVERS A distroless image, popularized by Google's GoogleContainerTools project, strips everything except the application and its language runtime and required shared libraries. There is no shell, no package manager, and no coreutils. Compared to Alpine, which is already minimal but still ships busybox and apk, distroless is typically smaller and crucially removes interactive tooling an attacker could leverage after a breach, and it carries far fewer scannable CVEs. It also avoids Alpine's musl libc, which occasionally causes glibc-compatibility issues for some binaries. The trade-off is debugging: with no shell you cannot docker exec into a running container, so you use Kubernetes ephemeral debug containers, the :debug variants that include busybox, or sidecar tooling. It also demands disciplined multi-stage builds since you must copy in exactly the right runtime files.

COMMON WRONG ANSWERS Believing distroless still has apk or apt. Assuming it always beats Alpine on size for every language. Ignoring the debugging cost. Confusing distroless with scratch, which has literally nothing including no CA certs or libc.

LIKELY FOLLOW-UPS How do you debug a distroless container in production? How does it interact with multi-stage builds? When would scratch be even more minimal, and what breaks?

ONE CONCRETE EXAMPLE A Java service final stage FROM gcr.io/distroless/java17 with only the JRE and the app jar copied in. Image scans show almost no OS-package CVEs and no shell for an attacker; when on-call needs to inspect a pod, they attach an ephemeral debug container with busybox rather than exec a shell that does not exist.

Read the original → github.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.