Base images

The FROM image decides most of the final size, the tools available and the security fixes you inherit. Full, slim, alpine and distroless variants trade convenience for size.

How it works

node:20, a Debian image with build tools, weighs about 1.1 GB; node:20-slim about 200 MB; node:20-alpine about 130 MB. Alpine uses musl instead of glibc, and distroless images have no shell and no package manager at all, only the runtime.

What breaks

Smaller is not free: native modules built for glibc fail on Alpine, and without a shell you can neither docker exec into a distroless container nor use a shell-form CMD. Pick the smallest base your program really runs on, and pin its version.

In a terminal

docker pull node:20-slim
docker pull node:20-alpine
docker images node

See it break, then fix it

Write the Dockerfile or the compose file, type the docker commands, and watch a simulated server run them through reboots, upgrades and traffic. Free to start.