containers/dockerignore
Container builds have a .dockerignore
| Severity | warning |
| Tiers | all |
| Stacks | any |
| Scope | root |
| Kind | expr |
| Source | library v0.8.0 |
| Selected by | fleetlint-recommended@v0.8.0 |
Requirement
A repository with a Dockerfile or Containerfile has a .dockerignore or .containerignore at the root, or a per-Dockerfile *.dockerignore; what it excludes is not checked.
Why
Without it the whole working tree, including .env files and the git history, is sent to the builder and can end up in a layer.
Applies when
tracked().exists(p, p.matches("(^|/)((Dockerfile|Containerfile)[^/]*|[^/]+\\.(Dockerfile|Containerfile|dockerfile|containerfile))$"))Check
file(".dockerignore") || file(".containerignore") || exists("*.dockerignore")Fix
Add .dockerignore listing .git, .env*, build output and anything the image does not need, so they stay out of the build context.
Agent instruction: Add .dockerignore with .git, .env*, the stack’s build output and dependency directories; check that the image still builds.
A finding that names no file points at .dockerignore.
Sources
- https://docs.docker.com/build/building/best-practices/ (guidance, Exclude with .dockerignore)
- https://fleetlint.org/baseline/#robustness
Generated by fleetlint docs from catalog v0.8.0.