Demos and production are different sports. This checklist covers what changes when Docker has to be reliable, secure and observable under real load.
Security and reliability defaults
- Scan images in CI (Trivy/Grype) and fail the build on high-severity CVEs
- Use BuildKit secret mounts (--mount=type=secret) instead of ENV for build-time secrets
- Drop Linux capabilities and run read-only root filesystems where possible
A production-minded config
A small, cache-friendly multi-stage Dockerfile for a Node service.
# syntax=docker/dockerfile:1
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine AS run
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
USER node
EXPOSE 3000
CMD ["node", "dist/server.js"]Operational best practices
- Pin base image tags (or digests) instead of :latest for reproducibility
- Order layers from least- to most-frequently changed to maximize cache hits
- Use multi-stage builds to keep runtime images tiny and attack surface small
- Add a HEALTHCHECK and run as a non-root user
In production, boring and reproducible beats clever every time.
Want senior help putting Docker to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.