Distroless image

Also known as: distroless container

On this page 7

A distroless image, also called a distroless container, is a minimal container image that contains only the application and the libraries it needs at runtime, without a shell, package manager or the usual utilities of a Linux distribution. In containers and cloud-native delivery, it is used to shrink the attack surface, reduce image size and cut the number of vulnerabilities reported by scanners.

The term is most closely associated with the Google distroless images, published under gcr.io/distroless, but it now describes a general practice. Several vendors and open-source projects build comparable images, and teams can create their own with a multi-stage build.

What a distroless image contains

A distroless image keeps the runtime essentials that a process needs to start and operate correctly, and removes everything intended for interactive administration. The result is a file system with very few files, in which the application binary is the only meaningful executable.

The table below contrasts the contents of a conventional base image with those of a distroless one.

ComponentConventional base imageDistroless image
Shellbash or sh presentAbsent
Package managerapt, apk or dnfAbsent
C libraryglibc or muslPresent where needed
CA certificatesPresentPresent
Time zone dataPresentPresent
User databaseFull /etc/passwdMinimal entries including nonroot
Core utilitiesls, cat, curl and othersAbsent
Contents of a typical distroless image

Because no shell exists, the Dockerfile must use the exec form of ENTRYPOINT, such as ["/app/server"], rather than the shell form. Any startup logic that would normally live in a shell script has to be moved into the application or handled by the orchestrator.

How distroless images are built

The standard approach is a multi-stage build. The first stage uses a full builder image with compilers and package tools to produce the application; the final stage copies only the resulting artifacts onto a distroless base image.

  1. Build stage: compile the code or install dependencies in an image such as a full Go, Java or Python toolchain.
  2. Copy stage: transfer the binary, bytecode or virtual environment into the distroless base with COPY --from.
  3. Runtime settings: set a non-root user, the working directory and the exec-form entry point.

Distroless bases come in language-specific variants. Choosing the right one avoids both missing libraries and unnecessary weight.

VariantIncludesSuitable for
staticCA certificates, time zones, user filesStatically linked Go or Rust binaries
basestatic plus glibc and OpenSSLDynamically linked C or C++ programs
ccbase plus libgcc and libstdc++Rust or C++ needing runtime libraries
javabase plus a Java runtimeJAR applications
python3base plus a Python interpreterPython services with vendored packages
nodejsbase plus a Node.js runtimeJavaScript server applications
Common distroless base variants

Most variants are also offered with a nonroot tag, which runs the process as UID 65532, and a debug tag, which adds a BusyBox shell for troubleshooting only.

Distroless images compared with other minimal bases

Distroless is one of several strategies for keeping a base image small. Each option trades convenience against minimalism differently, and the right choice depends on how the application is linked and how the team debugs production systems.

BaseApproximate sizeShell and packagesMain trade-off
Distroless staticAbout 2 MBNoneRequires static or self-contained binaries
Scratch0 MBNone, not even certificatesEverything must be added manually
AlpineAbout 5 to 8 MBsh and apkmusl libc can break some software
Debian slimAbout 25 to 30 MBbash and aptLarger surface but familiar tools
Minimal base image strategies

Compared with scratch, a distroless base adds the small but essential runtime files, such as CA certificates for TLS and a user database. Compared with Alpine, it keeps glibc compatibility where needed while removing the shell entirely.

Security benefits and their limits

The main benefit is a smaller attack surface. An attacker who gains code execution inside the process cannot simply open a shell, download tools with a package manager or run common reconnaissance commands, which makes post-exploitation noticeably harder.

Distroless images also produce far fewer scanner findings, because container image scanning reports vulnerabilities in packages that are no longer present. Fewer irrelevant findings let security teams focus on issues that actually affect the running code.

These advantages have clear limits. Distroless does not fix vulnerabilities in the application or its bundled dependencies, and a determined attacker can still execute code through the application runtime itself. It should be combined with rootless containers, read-only file systems, dropped Linux capabilities and regular rebuilds to pick up patched base layers.

Operational trade-offs and common mistakes

The most frequent complaint is harder debugging, because docker exec into a shell is impossible. Practitioners rely instead on ephemeral debug containers, such as kubectl debug in Kubernetes, which attach a tool-rich container to the target process namespace without changing the production image.

  • Shell-form commands: an ENTRYPOINT or CMD in shell form fails at start because /bin/sh is missing.
  • Shell-based health checks: probes that call curl or sh -c must be replaced with HTTP or gRPC probes or a built-in check command.
  • Missing shared libraries: a dynamically linked binary on the static variant fails with a file-not-found error at startup.
  • Stale base layers: images that are never rebuilt keep old library versions despite their minimal size.
  • Shipping debug tags: using the debug variant in production reintroduces the shell that distroless removes.

The simple explanation

A normal container image is like a moving box that holds the application plus a full toolbox. That toolbox includes a command line, an installer and dozens of small programs.

A distroless image packs only the application and the few parts it truly needs to run. There is less to carry, less to update and less for an attacker to use. The price is convenience: when something goes wrong, engineers must bring their own tools, because none are waiting inside.

How it is used in practice

A payments team runs a Go API in Kubernetes on a Debian-based image of about 120 MB. Every week, the container image scanner reports more than 60 vulnerabilities, almost all in system packages the service never uses, and engineers spend hours triaging them.

The team switches to a multi-stage build that compiles a static binary and copies it onto the distroless static nonroot variant. The final image drops to about 15 MB, scanner findings fall to a handful tied to the Go modules themselves, and pods pull and start faster during scaling events. Liveness probes are rewritten as native HTTP checks, and on-call engineers use kubectl debug with a temporary tools container when they need to inspect a running pod. The result is a smaller, quieter and easier to audit deployment with no change to application behavior.