docker-conventions
Skill7 starsChanged 2 days agoMITView on GitHub
Dockerfiles: base images, multi-stage builds, non-root USER, hadolint and Trivy; Compose file naming. TRIGGER when: editing or creating a `Dockerfile`, `Containerfile`, `.dockerignore` or Compose file (`docker-compose.yaml`, `compose.yaml`); user asks about base images, image size, container CVEs, non-root users, hadolint or naming a compose file. SKIP when: no Dockerfile or Compose file is touched and the user isn't asking about container builds.
- Pipes a download into a shell
- Deletes or force-pushes
- Installs packages
3 other projects use a version of this.
Adopted by
Most recently taken up by
- BaratovSokhibjon/skillstheir own version, first seen Nov 29, 2026
- leroyguillaume/skillsword for word, first seen Nov 22, 2026
- andr-ca/agentharnesstheir own version, first seen Oct 15, 2026
Other versions3 projects use a version of this.
Word for word · 1
- leroyguillaume/skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 2
- andr-ca/agentharness★ 1same name
- BaratovSokhibjon/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository54 other files it gives its agents.
- adr-conventionsSkill
- api-conventionsSkill
- architecture-conventionsSkill
- argocd-conventionsSkill
- ci-conventionsSkill
- config-conventionsSkill
- contributing-conventionsSkill
- councilSkill
- cryptography-conventionsSkill
- dependency-update-conventionsSkill
- diagram-conventionsSkill
- documentation-conventionsSkill
- frontend-conventionsSkill
- github-actions-conventionsSkill
- github-issue-conventionsSkill
- github-pr-conventionsSkill
- github-repo-settingsSkill
- gitlab-ci-conventionsSkill
- helm-conventionsSkill
- herdr-core-delegationSkill
- herdr-delegationSkill
- herdr-tui-delegationSkill
- kopf-conventionsSkill
- kubernetes-operator-conventionsSkill
- logging-conventionsSkill
- logo-conventionsSkill
- mise-conventionsSkill
- ollama-conventionsSkill
- openssf-conventionsSkill
- pr-conventionsSkill
- pre-commit-conventionsSkill
- project-metadata-conventionsSkill
- python-async-conventionsSkill
- python-conventionsSkill
- readme-conventionsSkill
- release-script-conventionsSkill
- release-supply-chain-conventionsSkill
- renovate-ci-conventionsSkill
- rest-conventionsSkill
- rust-build-conventionsSkill
- rust-conventionsSkill
- rust-http-conventionsSkill
- security-policy-conventionsSkill
- signal-handling-conventionsSkill
- sql-conventionsSkill
- starlight-conventionsSkill
- systemd-conventionsSkill
- system-user-conventionsSkill
- task-conventionsSkill
- terraform-conventionsSkill
- topic-splittingSkill
- ui-copy-conventionsSkill
- web-layout-conventionsSkill
- yaml-conventionsSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 0 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
Create a .dockerignore file to exclude unnecessary files from the build context (.git/, node_modules/, *.log, README.md, etc.).
- Very specific: line 40
use the upstream :nonroot tag and USER nonroot:nonroot.
- Very specific: line 87
Follow Linux (FHS) path conventions, with <appname> the project name:
- Very specific: line 92
Create a dedicated non-root user and group named after the app (use a short, recognisable name if the project name is long or not a valid …
- Very specific: line 152
Verify extraction actually works before trusting it: LOG_LEVEL=debug npx --package renovate -- renovate --platform=local --dry-run=extract.
- Very specific: line 185
Never end a Dockerfile without an explicit non-root USER.
- Very specific: line 186
Never run as root in the final image, even "temporarily".
- Very specific: line 204
Name the file
docker-compose.yaml: Always use this exact name, with the .yaml extension (not .yml), and not the shorter compose.yaml / … - Very specific: line 209
If a repo already has a compose.yaml, compose.yml, or docker-compose.yml, rename it to docker-compose.yaml rather than leaving the variant …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Docker conventions
Always:
- Create a
.dockerignorefile to exclude unnecessary files from the build context (.git/,node_modules/,*.log,README.md, etc.). - A Compose file is named per "Compose files" below.
- Pick the smallest runtime base image the app can actually run on. Every
package in the final image is a CVE waiting to be reported against you, and
the fastest way to fix a vulnerability is to not ship the package. Walk down
this ladder and stop at the first rung that works:
scratch— statically linked binaries (Rust withmusl, Go withCGO_ENABLED=0). Zero packages, zero CVEs, nothing to patch.- Distroless (
gcr.io/distroless/static,.../base,.../cc) — when you need libc, TLS roots, or/etc/passwdbut no shell or package manager. Prefer the:nonrootvariants. alpine— when you genuinely need a shell or a couple of apk packages.*-slim(debian:*-slim,python:*-slim) — when glibc or a distro runtime is unavoidable. Full distro images (debian,ubuntu,python:3.13,node:22) are a builder-stage-only thing; they never appear in the lastFROM.
- Always multi-stage. Compilers, headers, package managers, and dev dependencies stay in the builder; the runtime stage gets the artefact and nothing else. If the final stage installs a toolchain, the split is wrong.
- Distroless and
scratchhave nogroupadd/useradd. Two options, both fine, and both land on the same UID 65532 as the rule below:- use the upstream
:nonroottag andUSER nonroot:nonroot; - or create the user in the builder stage and copy
/etc/passwdand/etc/groupover. Either way the final stage still ends with an explicit non-rootUSER. The copied entry names/usr/sbin/nologin, a binary the final image does not contain — harmless, since an image with no shell and nosshdhas no login path to refuse in the first place.
- use the upstream
- Scan the built image in CI (
trivy image) and fail the build per the gate policy inci-conventions, which also owns the daily re-scan of the published image. A skinny base is what makes that gate cheap enough to keep enabled. - Scan the
Dockerfileitself withtrivy config, and fix every finding. These are theDS-xxxxchecks (DS-0002running as root,DS-0026missingHEALTHCHECK,DS-0001:latesttag,DS-0009relativeWORKDIR, …). Treat them as errors and fix at the source — no self-authorised ignores (ci-conventions). It is apre-commithook, so it also gates CI throughquality; arepo: local,language: systemhook, never a Docker-backed one (pre-commit-conventions):- repo: local hooks: - id: trivy-dockerfile name: trivy config (Dockerfile) entry: trivy config --exit-code 1 Dockerfile language: system pass_filenames: false files: (^|/)(Docker|Container)file$trivy configtakes one target, so a repo with severalDockerfiles gets one hook per file rather than passed filenames: setentryandfilesto that file's path (docker/api/Dockerfile,Containerfile). trivydoes not replacehadolint. Run both. They overlap on the obvious stuff (absoluteWORKDIR,cdinRUN,--no-install-recommends), but each catches things the other is blind to:- Only
hadolint: apk package version pinning (DL3018) — the pinning rule below has no Trivy equivalent, which by itself settles the question; apt list cleanup (DL3009); JSON notation forENTRYPOINT/CMD(DL3025); and ShellCheck on everyRUNline (SC2086unquoted expansion, etc.), which Trivy does not do at all. - Only
trivy: missingHEALTHCHECK(DS-0026), plus severity levels and the same report format as image/IaC scanning.
- Only
- Keep the runtime lean beyond the base image too:
--no-install-recommendsfor apt,--no-cachefor apk, nocurl/wget/bash"just for debugging", and health checks that use the app itself rather than an extra binary. - Language packages come from the lockfile (
npm ci,uv sync --locked,cargo build --locked), nevercurl … | shor an unpinnedpip install: the install rule isci-conventions'. - Follow Linux (FHS) path conventions, with
<appname>the project name:- Build in
/usr/local/src/<appname>(the builder stageWORKDIR). - Binary installed to
/usr/local/bin/(onPATH). - Config, if the app has any, under
/etc/<appname>/. - Any mutable state under
/var/lib/<appname>/.
- Build in
- Create a dedicated non-root user and group named after the app (use a
short, recognisable name if the project name is long or not a valid Linux
username), with UID 65532 and GID 65532, and end the
Dockerfilewith aUSERdirective. The account's other properties —nologinshell, locked password, no group it does not need — aresystem-user-conventions; the UID is the one thing that differs here, and the next paragraph says why. Why 65532 and not 1000: UID/GID must be > 10000 (TrivyKSV-0020/KSV-0021). Without user namespaces, a container UID is a host UID, and 1000 is the first human account on virtually every Linux box — so a container escape, ahostPathmount, or a shared NFS export lands with that user's identity. 65532 is the specific high UID upstream already agreed on (distroless:nonroot, Chainguard), which keeps the number identical whether you inherit the user or create it. Avoid 65534 — that'snobody/nogroup, shared by every unmapped process and squashed-to by NFS. Example (appmyapp):WORKDIR /usr/local/src/myapp # ... build, producing /usr/local/src/myapp/target/release/myapp ... RUN groupadd --system --gid 65532 myapp \ && useradd --system --uid 65532 --gid myapp \ --home /nonexistent --no-create-home --shell /usr/sbin/nologin myapp COPY --from=builder \ /usr/local/src/myapp/target/release/myapp /usr/local/bin/myapp USER myapp ENTRYPOINT ["/usr/local/bin/myapp"] chownonly what the app writes — never the binary.COPYwithout--chownlandsroot:root0755, which is what an executable should be: the process needs to execute it, not to own it, and a service that can rewrite its own binary rewrites it once and is still there after every restart. Give the app user only its state and cache paths, and preferreadOnlyRootFilesystem: trueat the orchestrator (seehelm-conventions) so the question stops arising.--homefollowssystem-user-conventions: the state directory, or/nonexistentwith--no-create-home.- Lint every
Dockerfilewithhadolint: thehadolinthook from thehadolint/hadolintrepo, never the Docker-backedhadolint-docker. - Fix every
hadolintwarning at the source. A green run is the only acceptable end state. - Pin
apkpackage versions (apk add pkg=1.2.3-r4) — this is DL3018, and the answer is to pin, not to silence. Keeping the pins current is Renovate's job, not a reason to skip them. Annotate each one so Renovate can see it:
Notes that save an hour of debugging:# renovate: datasource=repology depName=alpine_3_24/bash versioning=loose RUN apk add --no-cache bash=5.3.9-r1depNameis<repology-repo>/<package>, and the repo carries the distro release (alpine_3_24,debian_13). It does not follow a base-image bump on its own — when the base moves to a new release, the annotations must move with it or Renovate silently keeps resolving against the old one.- Multi-stage builds often sit on different distro releases per stage
(a toolchain image and a runtime image rarely move in lockstep). Check
each stage (
cat /etc/alpine-release) and annotate per stage. - Take the version from the image itself
(
apk list <pkg>/apt-cache policy <pkg>), not from Repology'sversionfield — Repology normalises (5.3.p9), and only itsorigversion(5.3.9-r1) is the string apk will accept. - Verify extraction actually works before trusting it:
LOG_LEVEL=debug npx --package renovate -- renovate --platform=local --dry-run=extract.
- Do not pin
aptpackage versions on Debian/Ubuntu — leaveDL3008ignored. This is a deliberate exception to the rule above, not an oversight, and# hadolint ignore=DL3008is pre-authorised here (the "never silence a rule on your own initiative" rule below does not apply to this one code). Two reasons:- The pin rots into a build failure.
deb.debian.orgserves exactly one version of each package per suite: the current one. The moment a security update or point release lands,curl=8.14.1-2+deb13u4stops existing and every build breaks — including builds of tags that used to work. - A frozen pin means frozen CVEs. A stable suite only moves for security
updates, so an unpinned
apt-get installon a rebuild picks up precisely the patches you want — while a pin freezes the vulnerability until a human notices. That is backwards for an image you are also scanning with Trivy. Reproducibility is recovered at the layer where it actually works: pin the base image by digest and rebuild on a schedule. Not with apt pins. The ignore sits on theRUNit covers, so a third-party apt install elsewhere in the file is still checked:
What still gets pinned, because those pools keep old versions: third-party apt repos (# hadolint ignore=DL3008 RUN apt-get update \ && apt-get install --yes --no-install-recommends ca-certificates \ && rm -rf /var/lib/apt/lists/*download.docker.com, PostgreSQL, NodeSource), PyPI, npm, and GitHub release assets. Hoist third-party apt versions intoARGs at the top of theDockerfileso every version knob lives in one place. - The pin rots into a build failure.
Never:
- Never end a
Dockerfilewithout an explicit non-rootUSER. - Never run as
rootin the final image, even "temporarily". - Never ship a full distro image as the runtime stage because it was
convenient, because the builder already used it, or because "we might need
to exec into it". Debugging is what
docker debug, ephemeral containers, and a separate-debugtag are for. - Never use a floating tag (
:latest,:3,:bookworm) in aFROM. Pin the specific version, and pin by digest where the registry supports it (image:1.2.3@sha256:…) — the dependency bot keeps both current. A floating tag means the image you scanned is not the image you shipped. - Never silence a scanner or
hadolintfinding on your own initiative — the rule is inci-conventions. A# hadolint ignore=DLxxxxgoes in only when the user expressly asked for that specific code. The single standing exception isDL3008(apt version pinning), which is pre-authorised — see the apt rule above. Everything else, includingDL3018, still needs an explicit ask.
Compose files
- Name the file
docker-compose.yaml. Always use this exact name, with the.yamlextension (not.yml), and not the shortercompose.yaml/compose.ymlform. Compose discovers all of these automatically, so the choice is about consistency: every Compose file across every project carries the same recognisable name. - If a repo already has a
compose.yaml,compose.yml, ordocker-compose.yml, rename it todocker-compose.yamlrather than leaving the variant in place. - YAML inside the file follows
yaml-conventions.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

