Guides / Containers

Choosing a Docker base image: Debian slim, Alpine, distroless or scratch

beginnerUpdated 26 Nov 2026900 words

The base image decides much of what a vulnerability scanner finds in your image, and whether you can open a shell in a running container. The table at the end suggests a base for each kind of application.

What each option contains

Base Example tags Contents
Full distribution debian:trixie, ubuntu:24.04 a minimal installation of the distribution with a shell, the package manager and the core utilities; more packages than an application needs
Slim debian:trixie-slim, python:3.13-slim Debian without documentation, man pages and some locales, with a shell and apt; the official Python, Node.js and Ruby images have -slim tags built on it
Alpine alpine:3.24, node:24-alpine a small distribution built on musl libc and BusyBox, with the package manager apk
Distroless gcr.io/distroless/static-debian13, base-debian13, cc-debian13, python3-debian13, java21-debian13, nodejs24-debian13 and others Debian packages without a package manager or shell, based on Debian 13 (November 2026)
scratch scratch the empty image: only the files you copy in

How many packages a scanner sees

Counted in November 2026 with the package manager of each image:

Image OS release Packages
debian:bookworm-20261027-slim Debian 12 88 (dpkg-query -W)
python:3.13-slim Debian 13 87 (dpkg-query -W), plus Python
alpine:3.24.3 Alpine 3.24 16 (apk info)

A distroless static image holds CA certificates, time zone data, a /tmp directory and an /etc/passwd entry; base adds glibc and libssl. scratch holds nothing. The application adds its own dependencies in every case, and a Python or Node.js application often brings more packages through pip or npm than the base image has.

A finding in a library your program never loads is less urgent than one in OpenSSL, which most network services use. Each package still adds lines to the scanner report that someone has to read.

musl and glibc

Alpine uses musl libc; Debian, Ubuntu, RHEL and distroless base use glibc. Most software runs on both.

  • Binaries compiled against glibc do not run on Alpine as they are. Build them on Alpine, or link them statically.
  • Python packages with C extensions ship prebuilt wheels for glibc (manylinux) and, where the project publishes them, for musl (musllinux, defined in PEP 656). Without a musl wheel, pip compiles the package during the build, which needs a compiler in the build stage and takes longer.
  • Go programs built with CGO_ENABLED=0 are static and run on any base, including scratch and distroless static.

Measured in the images above: ldd --version in debian:bookworm-20261027-slim prints GLIBC 2.36, and ldd in alpine:3.24.3 prints musl libc (x86_64) Version 1.2.6.

Support periods

Alpine supports each branch in its main repository for about two years, Debian each release for about three years plus LTS, Ubuntu LTS for five years of standard support. After that, images on the release do not get fixes. The dates per release are in End-of-life dates of Linux releases.

Distroless images follow Debian. The README says that images without a Debian version in the name "will currently select -debian13 images, but that will change in the future". Pin the variant with the Debian version (static-debian13) so the switch happens when you decide.

Debugging without a shell

In distroless and scratch images, docker exec -it app sh fails because there is no shell. Ways around it:

  • Distroless images have :debug tags with a BusyBox shell. Use them for a debugging session, not in production.
  • Start a second container in the namespaces of the first. With docker run --rm -it --pid=container:app --network=container:app alpine:3.24 sh you see the processes and network of app, and its files under /proc/1/root/ (as far as permissions allow).
  • Log enough that you rarely need a shell.

Multi-stage builds

Whatever the final base, build in a full image and copy only the result:

FROM golang:1.27-bookworm AS build
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -o /out/server ./cmd/server

FROM gcr.io/distroless/static-debian13:nonroot
COPY --from=build /out/server /server
ENTRYPOINT ["/server"]

The compiler, the source code and the build tools stay in the first stage. The nonroot tag runs the program as UID 65532.

Which one to pick

Application A good start
Static Go or Rust binary distroless static, or scratch with CA certificates and time zone data copied in
Python, Node.js, Ruby the -slim variant of the official language image; Alpine if the dependencies have musl builds
PHP the official php image (Debian) or its -alpine variant
Java a JRE image on Debian or Ubuntu, or distroless java
Something that needs many system tools debian:trixie-slim or ubuntu:24.04
A tool you docker exec into often a slim or full image, since you need the shell

Where you can, use one base family for all images. They then share package names and install commands, and a fix in the base reaches all of them with the next rebuild.

Sources

Check your servers every day

The Vulnpocalypse collector reports the packages and settings of a server once a day, and the digest lists what to fix, most urgent first.

Start free