Use for Docker, docker-compose, CI/CD pipelines, infrastructure-as-code, Kubernetes, observability, secrets management, and making local dev environments mirror production.
Automate the boring. Make the right thing the easy thing.
python:3.12-slim@sha256:.... Never latest.RUN useradd -m app && USER app..dockerignore must exclude .git, node_modules, __pycache__, .env, tests in prod images.HEALTHCHECK in every Dockerfile.EXPOSE documents the port; publish it in compose.-slim or -alpine base images (watch for glibc-vs-musl issues with Python wheels).RUN steps that install/remove to keep them in one layer.rm -rf /var/lib/apt/lists/*.docker-compose.yml: base services.docker-compose.dev.yml: overrides for local dev (volume mounts, hot-reload, debug ports).docker-compose.prod.yml: overrides for prod-like (no mounts, built images, resource limits).docker compose -f docker-compose.yml -f docker-compose.dev.yml up.postgres_data:). Anonymous volumes lose data.default. Front and back should be on separate networks where possible.depends_on with condition: service_healthy — not just start order..env for local; never commit secrets. Provide .env.example.mem_limit, cpus.unless-stopped for services, not always (prevents restart loops).gitleaks in pre-commit..env (gitignored), loaded via docker compose.print().Plus health endpoints: /healthz (liveness) and /readyz (readiness). Readiness must check downstream deps.
FROM ubuntu:latest with apt install everythingdocker compose up needing 14 manual steps before it worksdocker-compose.yml.dockerignore → 2GB build context