Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Docker & containersCloud / DevSecOps series

Alpine vs Debian base images

Choosing a base image is one of the first decisions in a Dockerfile, and the Alpine-versus-Debian debate comes up every time. Both are good; they trade size for compatibility.

Quick reference

ALPINEDEBIAN
Size~5 MB base~30 MB (slim)
C librarymuslglibc (standard)
Package managerapkapt
CompatibilityOccasional issuesJust works
Build painSometimes highLow
Best forSmall, simple appsMost apps, especially Python

ALPINE (Tiny base image): A few MB. Smaller images, smaller attack surface, faster pulls.

Example: FROM python:3.12-alpine

DEBIAN (Standard base (slim)): Bigger, but familiar, compatible, and painless to build on.

Example: FROM python:3.12-slim

  • Alpine → smallest images, when your deps cooperate.
  • Debian slim → the safe default. Small enough, no surprises.

Explained

Alpine is tiny, a base of about 5 MB, because it uses musl libc and busybox instead of the standard GNU tools. Smaller images mean faster pulls, less storage, and a smaller attack surface, which security people love. Its package manager is apk.

Debian slim is the trimmed-down Debian base, around 30 MB. It uses glibc, the standard C library almost everything is built and tested against, and apt for packages. It is bigger than Alpine but still far smaller than the full image, and it rarely surprises you.

The catch with Alpine

Because Alpine uses musl instead of glibc, some software behaves differently or needs to be recompiled. In Python especially, packages with C extensions (data science, image processing, database drivers) may have no prebuilt Alpine wheel, so pip compiles from source. That makes builds slow and sometimes fails outright, and it can introduce subtle runtime differences. The small image you wanted ends up costing hours of build pain.

How to choose

Alpine when the app is simple, the dependencies are pure or known to work, and image size really matters. Debian slim as the default, especially for Python apps with compiled dependencies. It is small enough for almost everyone and it just works.

A good middle path: start on Debian slim, ship, and only move to Alpine later if image size becomes a real problem and your dependencies cooperate. Measure, do not assume.

Smaller is not always better.

More notes: Docker & containers

Open in the notes app: search, filters, copy This note on GitHub