LayerLint documentation
Dockerfile linter rules for Docker layer cache issues.
- Dependency install runs after broad source copy (high) — Copying the full source tree before installing dependencies invalidates the dependency cache on every code change.
- Dependency install without lockfile (high) — Installing dependencies without copying the lockfile defeats reproducible builds.
- Unpinned base image tag (medium) — Using :latest or an implicit latest tag makes builds non-reproducible.
- Secrets copied into the image (high) — Secrets copied into layers remain in image history even if deleted later.
- Container runs as root (high) — Containers default to root. Prefer a non-root USER before CMD/ENTRYPOINT.
- .dockerignore file is missing (medium) — Without .dockerignore, the build context may include .git, node_modules, secrets, and other unnecessary files.
- Build without BuildKit cache mount (low) — Package installs and compiles are faster when BuildKit cache mounts are used.
- apt-get update separated from install (medium) — Running apt-get update in a separate layer from install leaves a stale package index.
- Multiple broad COPY instructions (medium) — Copying the full tree more than once wastes layers and hurts caching.
- Redundant dependency install (medium) — Running the same dependency install more than once usually means layer ordering is wrong.
- ADD used instead of COPY (low) — ADD has magic behavior (auto-extract, remote URLs). Prefer COPY unless you need that behavior.
- Download without checksum verification (high) — Downloading binaries without verifying checksums is a supply-chain risk.
- Missing HEALTHCHECK instruction (medium) — Services that EXPOSE a port should declare a HEALTHCHECK so orchestrators can detect unhealthy processes. CLI images without EXPOSE are skipped.
Markdown: rules.md, ci-cd-integration.md