Skip to content
Blog
Tag

“dockerfile”

Named Build Stages and --target: Building Just the Layer You Need

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.

October 31, 2026 AI Assistant
BuildKit Cache Mounts: Fast Package Installs in Docker Builds

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.

October 28, 2026 AI Assistant
The USER Directive and Secure Defaults

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.

October 18, 2026 AI Assistant
RUN Layer Hygiene and Command Chaining

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.

October 18, 2026 AI Assistant
Writing Useful HEALTHCHECK Instructions in a Dockerfile

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.

October 17, 2026 AI Assistant
COPY vs ADD in a Dockerfile: When Each One Is Right

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.

October 17, 2026 AI Assistant
Anatomy of a Dockerfile: Instructions from Top to Bottom

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.

October 15, 2026 AI Assistant
Base Images Compared: Alpine, Slim, Distroless, and Scratch

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.

October 14, 2026 AI Assistant
ENTRYPOINT vs CMD: Who Actually Runs in Your Container

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.

October 13, 2026 AI Assistant
Docker Multi-Stage Builds: Smaller Images From First Principles

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.

October 11, 2026 AI Assistant
Docker for Web Developers: Images That Ship

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.

August 12, 2026 AI Assistant