Docker (containers and images) checklist¶
Copy this list into a pull request, design review or project kickoff and tick what applies. Rules are grouped by level and sorted by score (criteria). Each links to the file that explains it and cites its sources. Automatable names tools that can check the rule in CI (see the file's "How to enforce" section).
Also apply the general checklist.
This file is generated by python3 scripts/rank.py fix from the guidelines. Don't edit it by hand.
Strongly recommended (9–10)¶
-
DOCKER-1(9) Run the application as a non-root user: create a user in the Dockerfile and switch to it withUSER. (specific/docker) Automatable: Docker Scout policy evaluation, Hadolint. -
DOCKER-2(9) Never pass secrets to a build throughARG,ENVor copied files. Use secret mounts or SSH mounts. (specific/docker) Automatable: Docker build checks, Trivy. -
DOCKER-12(9) Never mount the Docker socket into a container, and never expose the daemon over unauthenticated TCP. (specific/docker)
Recommended (6–8)¶
-
DOCKER-3(8) Pin base images to a tag plus digest, and let a bot such as Dependabot update both. (specific/docker) Automatable: Hadolint. -
DOCKER-10(8) Scan images for known vulnerabilities in CI, fail the build above an agreed severity, and keep scanning the images you have deployed. (specific/docker) Automatable: Docker Scout policy evaluation, Trivy. -
DOCKER-4(7) Use multi-stage builds so that the final image contains only what the application needs to run, on a small base image from a trusted source. (specific/docker) -
DOCKER-5(7) Rebuild images often, with--pullto fetch fresh base images, so that security fixes in the base image reach production. (specific/docker) Automatable: Docker Scout policy evaluation. -
DOCKER-6(7) Start the main process with the exec form, such asENTRYPOINT ["app"], so that it runs as PID 1 and receivesSIGTERM. (specific/docker) Automatable: Docker build checks, Hadolint. -
DOCKER-13(7) Run containers with least privilege: never use--privileged, drop all capabilities and add back only those needed, setno-new-privileges, and use a read-only root file system where possible. (specific/docker) -
DOCKER-14(7) Give containers runtime secrets as Compose or orchestrator secrets, mounted as files, rather than as environment variables. (specific/docker) -
DOCKER-7(6) Order Dockerfile instructions from least to most often changed: copy the dependency manifests and install dependencies before copying the source code. (specific/docker) -
DOCKER-8(6) Keep the build context small with a.dockerignorefile. (specific/docker) -
DOCKER-9(6) Give each container one concern: run the web app, the database and the cache as separate containers. (specific/docker) -
DOCKER-11(6) Attach SBOM and provenance attestations to the images you publish, and sign them so that deployments can verify where an image came from. (specific/docker) Automatable: Docker Scout policy evaluation. -
DOCKER-15(6) Make services wait for their dependencies to be ready, not only started: give the dependency ahealthcheckand usedepends_onwithcondition: service_healthy. (specific/docker) -
DOCKER-16(6) Keep one basecompose.yamland put environment-specific changes in extra files, such ascompose.override.yamlfor development andcompose.production.yamlfor production. In production, don't bind-mount application code. (specific/docker)