Dockerfile security review skill. No external tools needed -- this is
pure code review of Dockerfile content.
When to activate
Use this skill when the repository contains Dockerfile or
docker-compose.yaml files.
Scanner approach
Read each Dockerfile with read_file. Analyze line by line for the
following checks.
Checks
1. Running as root
- No
USERinstruction means the container runs as root USER rootwithout switching to a non-root user later- Flag as high severity
2. Unpinned base image
FROMusing:latesttag or no tag at all- Recommend pinning to a specific version or digest
3. Secret exposure
ENVorARGinstructions with password, secret, key, or token
values baked into the image
COPY .envorCOPYof credential files into the image- Flag as critical -- secrets persist in image layers
4. COPY vs ADD
ADDfrom remote URLs (useCOPY+curlinstead for
transparency and caching)
ADDof archives without needing extraction (useCOPY)
5. Missing HEALTHCHECK
- No
HEALTHCHECKinstruction in the final stage - Flag as low severity (best practice)
6. Package manager hygiene
apt-get installwithout--no-install-recommends- Missing
rm -rf /var/lib/apt/lists/*cleanup in the same layer - Large image size from uncleaned package caches
7. Multi-stage builds
- Single-stage builds that include build tools (gcc, make, npm) in
the final image
- Recommend multi-stage to separate build and runtime
MUST flag
- No
USERinstruction (runs as root by default) - Secrets in
ENVorARGinstructions COPY .envorCOPYof known credential filesADDfrom remote URLs
MUST NOT flag
- Dev/CI Dockerfiles (Dockerfile.dev, Dockerfile.test, Dockerfile.ci)
scratchordistrolessbase images (no USER needed, no shell)- Multi-stage builds where root is only used in the builder stage
HEALTHCHECKabsence in builder stages (only matters in final stage)