Choose the right Docker official image
Docker Hub’s official images are curated, regularly patched starting points for containers. This reference lists the most-used ones — base OS layers, language runtimes, databases and servers — with their typical tags, the base OS each variant uses, and notes on the traps that bite people, like Alpine’s musl libc.
How it works
A Dockerfile starts from a base image with FROM. Picking the right tag balances
size, compatibility and build speed:
# multi-stage: build in a toolchain image, ship a slim runtime
FROM node:22 AS build
WORKDIR /app
COPY . .
RUN npm ci && npm run build
FROM node:22-slim
WORKDIR /app
COPY --from=build /app/dist ./dist
CMD ["node", "dist/server.js"]
The -slim variant keeps glibc for compatibility while dropping extras; -alpine
goes smaller still but uses musl, which occasionally breaks prebuilt binaries.
Tips and notes
- Pin explicit versions for reproducible builds; avoid
latestin production. - Reach for
-slimfirst; only move to-alpineonce you have confirmed your dependencies build and run under musl. - Use multi-stage builds so compilers and source never reach the final image.
- For static Go or Rust binaries, a
scratchor distroless base gives the smallest, most locked-down result.