Module 05 · Lesson 01

Base Image Footprint

Why a smaller image is a smaller attack surface, and how to actually shrink one.

Hands-on
Learning objectives
  • Explain what a smaller base image removes, in concrete terms.
  • Prove a capability is gone rather than assuming from the tag.
  • Weigh distroless against debuggability.
Container images Footprint

What an attacker inherits from your base image

Anyone who executes code in your container gets whatever the image ships. A full distribution base hands them a package manager to install tools, a shell to script with, and networking utilities to move around with. A minimal image hands them their own binary and very little else.

terminal
$kubectl exec deploy/worker -- sh -c "command -v apt-get bash"; echo "exit: $?"
exit: 1
The property is the absence, not the tag

The security claim is not "the image name looks minimal". It is that these specific capabilities are unavailable to anyone who compromises the container. That is a testable statement, and the command above is the test.

A spectrum, not a binary

BaseContainsTrade-off
ubuntu, debianPackage manager, shell, full userlandEasy to debug, large attack surface
alpineShell, busybox utilities, apkSmall, still fully interactive
busyboxA shell and basic utilities onlySmaller, no package manager
distrolessThe application and its runtime, no shell at allNothing to get a shell in, and kubectl exec -- sh no longer works
scratchNothingOnly viable for static binaries
Distroless changes how you debug

With no shell, kubectl exec gives you nothing, which is exactly the point and also a real operational cost. The answer is ephemeral debug containers, which attach a tooling image to a running pod without the workload image carrying those tools permanently: kubectl debug -it POD --image=busybox --target=app.

Fewer packages, fewer CVEs

A scan of a full distribution base routinely reports hundreds of findings in packages your application never calls. They are still findings, they still need triage, and they still appear on the report someone has to sign off. Shrinking the base is the cheapest way to make that list short enough to act on, which connects directly to scanning.

You change a Deployment from ubuntu to busybox. How do you confirm the security benefit?

What is the operational cost of a distroless image?

Why does base image choice affect your vulnerability report so much?

Recap

A smaller base removes the tools an attacker would otherwise inherit, and the property to verify is their absence rather than the tag. Distroless goes furthest and costs you interactive debugging, which ephemeral debug containers give back. Next: proving where an image came from.