“dockerfile”
Named Build Stages and --target: Building Just the Layer You Need
Name your Dockerfile stages with FROM ... AS, then build only the stage you need with --target — test images in CI, lean runtime images in release, one file.
BuildKit Cache Mounts: Fast Package Installs in Docker Builds
RUN --mount=type=cache gives Docker builds a persistent, shared cache across builds — pip, npm, apt, Go modules, and Cargo all get dramatically faster with it.
The USER Directive and Secure Defaults
Containers run as root by default — how the USER directive, explicit UIDs, file ownership, and gosu change that, and what USER doesn't fix.
RUN Layer Hygiene and Command Chaining
How to structure RUN instructions — chain update with install, clean up in-layer, avoid over-chaining, and keep the build cache working for you.
Writing Useful HEALTHCHECK Instructions in a Dockerfile
A HEALTHCHECK that always passes is worse than none. A practitioner guide to the instruction forms, timing options and defaults, how health status reaches docker ps and Compose depends_on, and the checks that lie while your app is broken.
COPY vs ADD in a Dockerfile: When Each One Is Right
COPY and ADD look interchangeable but are not. The exact behavioral differences - URL fetching, tar extraction, --chown, --from, cache invalidation - and why the guidance is to prefer COPY.
Anatomy of a Dockerfile: Instructions from Top to Bottom
FROM, WORKDIR, COPY, RUN, CMD, ENTRYPOINT, USER, HEALTHCHECK — what each instruction does, the order they run in, and how they shape your image layers.
Base Images Compared: Alpine, Slim, Distroless, and Scratch
The FROM line decides your image size, your CVE count, your glibc-vs-musl headaches, and whether you have a shell to debug with. A practical guide to choosing a base image.
ENTRYPOINT vs CMD: Who Actually Runs in Your Container
ENTRYPOINT sets the executable, CMD sets the default arguments — and the rules for how they combine, override, and break signal handling are the ones every Docker user eventually needs.
Docker Multi-Stage Builds: Smaller Images From First Principles
How multi-stage Docker builds shrink images, cut attack surface, and improve caching — with real examples for Go, Node.js, and Python.
Docker for Web Developers: Images That Ship
A code-first walkthrough of writing Dockerfiles for web apps that actually ship: multi-stage builds, non-root users, .dockerignore, secrets, BuildKit caching, and docker compose for local dev.