← ClaudeAtlas

dockerfile-patternslisted

Dockerfile + container discipline — multi-stage builds (build → runtime); pinned base image with tag + sha256 digest; non-root USER mandatory; COPY over ADD (except verified tarball); chained apt-get install + cache cleanup in same RUN layer; explicit WORKDIR; exec-form CMD/ENTRYPOINT; layer ordering least-frequent → most-frequent change; EXPOSE documentary; HEALTHCHECK for long-running services; OCI labels (org.opencontainers.image.*); .dockerignore mandatory; Hadolint at strict ruleset; BuildKit secret mounts (--mount=type=secret) never ENV/ARG for secrets. Auto-fires on Dockerfile + Compose files.
Nmor/the-claude-council · ★ 9 · Code & Development · score 69
Install: claude install-skill Nmor/the-claude-council
> Migrated 2026-06-02 from `~/.claude/rules-library/dockerfile/` as part of the lazy-rules-loading plan. Phase H will delete the source files. # dockerfile-patterns <!-- ============================================================ Section: dockerfile/coding-style.md ============================================================ --> # Dockerfile Coding Style > Auto-fires on every `Dockerfile`, `Dockerfile.*`, `*.dockerfile`, > `Containerfile`, and `*.containerfile` file. Standards: **Dockerfile > reference (docs.docker.com)**, **OCI Image Specification 1.1.1** > (Sept 2024), **BuildKit syntax 1.20+**, **Hadolint** lint rule > catalogue, **CIS Docker Benchmark 1.7**, **NIST SP 800-190** > (Application Container Security Guide). ## Core Principle **Every Dockerfile is multi-stage by default; pins the base image to a versioned tag plus `@sha256:` digest; runs as a non-root user; declares an explicit `WORKDIR`; uses `COPY` over `ADD`; chains `apt-get update` with `apt-get install` and cleans the package cache in the same `RUN` layer; declares `HEALTHCHECK` and the runtime contract via `EXPOSE` (documentary), `CMD` (default command), and `ENTRYPOINT` (executable form); refuses `latest` tags, root accounts, secrets at build time, shell-form RUN with interpolated variables, and ADD with untrusted URLs.** A Dockerfile is the recipe for every replica that will ever run the service. Sloppy Dockerfiles produce 2 GB images, root-running containers, mystery dependency versio