Quick reference
| ALPINE | DEBIAN | |
|---|---|---|
| Size | ~5 MB base | ~30 MB (slim) |
| C library | musl | glibc (standard) |
| Package manager | apk | apt |
| Compatibility | Occasional issues | Just works |
| Build pain | Sometimes high | Low |
| Best for | Small, simple apps | Most 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
- P277The Docker command cheat sheet
- P1995 Dockerfile mistakes to avoid
- P1949 docker commands for building and shipping images
- P1649 docker compose commands for daily work
- P163Anatomy of a container image reference
- P152Docker Compose vs Kubernetes
- P147Quiz: 3 container questions
- P133Anatomy of a docker run command
Open in the notes app: search, filters, copy This note on GitHub