
Container Config Checker — Dockerfile & Compose
Container Config Checker
A Dockerfile reads fine and still ships node:latest, runs as root, bakes a token into an ENV, and pipes curl into a shell. A compose file mounts /var/run/docker.sock into a service — which is root on the host. None of these are syntax errors; docker build runs them without complaint.
Container Config Checker reads the file the way a careful reviewer would and names each problem, ranked most severe first.
$ python3 scripts/container_config_checker.py examples/Dockerfile.bad
[HIGH ] runs-as-root examples/Dockerfile.bad:1
no USER instruction; the container runs as root
[HIGH ] secret-in-env examples/Dockerfile.bad:3
API_TOKEN is set to a literal value
[HIGH ] curl-pipe-shell examples/Dockerfile.bad:11
curl/wget piped into a shell
[MEDIUM] base-image-latest examples/Dockerfile.bad:1
FROM node:latest
[LOW ] workdir-relative examples/Dockerfile.bad:5
WORKDIR app
[LOW ] apt-no-clean examples/Dockerfile.bad:9
apt-get install without rm -rf /var/lib/apt/lists/* leaves cache in the image
[LOW ] apt-no-no-install-recommends examples/Dockerfile.bad:9
apt-get install without --no-install-recommends pulls extra packages
[LOW ] multiple-cmd examples/Dockerfile.bad:16
2 CMD instructions found
[INFO ] no-healthcheck examples/Dockerfile.bad:1
no HEALTHCHECK; the orchestrator cannot tell if the app is alive
[INFO ] expose-privileged-port examples/Dockerfile.bad:13
EXPOSE 80
10 finding(s): 3 high, 1 medium, 4 low, 2 info
The same app done carefully (examples/Dockerfile.good) prints No findings. and exits 0.
What it does:
- Checks 21 kinds of problem across Dockerfiles and compose files, each with a stable rule id and a severity (high / medium / low / info)
- Reads the file, it does not grep it: line continuations (
\) are joined, a#inside quotes is not a comment, and aFROM ... AS buildstage name is remembered so a laterFROM buildis not mistaken for an unpinned image - Does not false-fire on placeholders:
ENV API_KEY=${API_KEY}passes,ENV API_KEY=realvalueis flagged - Three outputs: human text, json, and SARIF 2.1.0 for a code-scanning dashboard
- A
--fail-ongate (default medium) so CI fails only at the level you choose, plus--dir,--list,--min-severityand--ignore
Honest limits: it reads the text of the file. It does not run the build and does not resolve what a base image contains. The compose reader handles the common shape, not every YAML feature. It is a reviewer's checklist caught by a script, not a sandbox.
Python 3.8+, macOS or Linux, standard library only. The checker never builds or runs Docker, makes no network calls, and needs no credentials.


