Dockerfile & Compose Auditor
Your Dockerfile decides who your container runs as and what secrets ship inside it. Read it before an attacker pulls the image and does.
A Dockerfile audit is a static review of a Dockerfile — and, when you use one, its docker-compose.yml — checked instruction by instruction against known-good container practice, without building or running anything. Paste yours here and this auditor reads it in your browser — never uploaded — and flags unpinned base images, a missing USER (the container runs as root), secrets baked into ENV or ARG, curl | sh installs, broad COPY . . context copies, privileged compose services and docker.sock mounts, with a 0–100 score. The companion article Dockerfile and compose audit guide explains each check. Also see the Nginx Config Auditor and the SBOM Vulnerability Scanner.
Last updated:
1. Audit a Dockerfile
Results
🔒 The audit runs entirely in your browser: the Dockerfile and compose file are never uploaded, never stored, and never sent anywhere. These files can name registry credentials, internal image names and host paths — that is exactly why they stay on your machine.
What a Dockerfile and a compose file are
A Dockerfile is a recipe: each instruction (FROM, RUN, COPY, ENV, USER, CMD…) adds a layer or sets metadata, and the final image is the stack of those layers. A multi-stage build has several FROM lines — early stages compile, the last stage is the image that actually ships, which is why this auditor judges USER and the base-image pin on every stage but weighs the final stage most.
A docker-compose.yml is the runtime half: it names the services built from those images and how they run — published ports, mounted volumes, environment values, privileged mode, cap_add, the network mode and the restart policy. A careful Dockerfile can be undone by a careless compose file: privileged: true or a mounted Docker socket hands the container the host.
Two Dockerfile facts surprise people. First, ENV and ARG values are not hidden: they are readable with docker inspect and docker history by anyone who can pull the image, forever — deleting the file that held a secret in a later layer does not remove it from the earlier one. Second, an image reference without a tag means :latest, and :latest is a moving target — the same Dockerfile can build a different image tomorrow.
The daemon socket deserves its own warning: mounting /var/run/docker.sock into a container is not “access to Docker status”, it is root-equivalent control of the host — the container can start a new privileged container with the host filesystem mounted and own the machine. The same goes for a volume that mounts the host root /.
What this auditor does — and what it does not
It parses the Dockerfile in your browser — instructions, line continuations, comments and build stages — and, if you add one, the compose YAML, then runs 30 rules over both: base-image pinning, the final-stage USER, secret-shaped ENV/ARG values, remote-code installs, package-manager hygiene, sensitive EXPOSE ports, missing HEALTHCHECK, privileged services, host networking, socket and root mounts, capability grants, published database ports, restart policies and resource limits. Scoring starts at 100; each error deducts 10 (capped at 50), each warning 4 (capped at 28), each info 1 (capped at 10). Bands: 90+ Excellent, 70–89 Good, 50–69 Needs work, below 50 Poor.
It does not build the image, run it, or scan it: it reads exactly the text you give it. A finding is a pattern, not a verdict — EXPOSE 3306 on an image that only ever runs on an internal network is documentation, and a build stage that runs as root is normal when the final stage drops privileges. Read each finding with its evidence and decide with your context.
The broken demo pair is a small app built to trip the rules on purpose — an untagged ubuntu base, a baked-in API key, a curl | sh install, SSH and MySQL ports exposed, and a compose file with privileged: true and the Docker socket mounted — and scores 12 (Poor) with 30 findings. The hardened demo is the same shape with every finding fixed, and scores 100.
Be honest about what a static audit cannot see
This audit reads text. It cannot see the vulnerabilities inside your base image — a perfectly pinned, rootless Dockerfile can still ship a critically vulnerable library, and finding those is a scanner’s job (that is what image scanners and the SBOM Vulnerability Scanner are for). It also cannot see your .dockerignore — that file is not part of what you paste here, so a broad COPY . . is flagged as a risk, never as a proven leak — nor the runtime flags, secrets store or network policy the container actually runs under.
And a high score is not a safe container. The rules encode widely agreed practice — Docker’s own Dockerfile best practices and the CIS Docker Benchmark — but they are a checklist, not a penetration test. “No findings” means no risky pattern was found in this text — not that the image or the host behind it is secure.
Key facts
| Pinning | Naming a base image by an exact tag — better, by its @sha256: digest — so the build cannot silently pick up a different image tomorrow. No tag at all means :latest. |
| USER | The account the container process runs as. With no USER instruction, that is root: a breakout or a compromised app starts with host-level privileges inside the container’s namespaces. |
| docker history | Every layer and the instruction that created it — including ENV and ARG values — stays readable in the image metadata. Secrets baked in at build time are published, not stored. |
| privileged | A compose/runtime flag that gives the container nearly all host capabilities and device access. It is the single most dangerous line in a compose file. |
| docker.sock | The Docker daemon’s socket. Mounting it into a container is root-equivalent on the host: the container can create a new privileged container and take the machine. |
| HEALTHCHECK | An instruction that tells Docker how to test whether the container is actually working, not just running — orchestrators use it to restart or drain a wedged container. |
| Build context | Everything in the directory sent to the builder. COPY . . copies all of it into the image — including any .env or key files your .dockerignore forgot to exclude. |
| Format reference | Dockerfile best practices — Docker documentation |
Frequently asked questions
Why does the audit run in my browser instead of on a server?
Because these files can name things you do not publish: registry and image names, internal host paths, published ports, and — in the worst case — the very secrets this audit hunts for. Sending that to a server to audit it would create the exact exposure the audit is meant to catch. Parsing it locally means the files never leave your machine.
My files have findings — is my container unsafe?
Not necessarily. A finding is a pattern that matched, and some matches are intended: a build stage running as root, a database port exposed on an internal-only image. Start with the errors — baked-in secrets, a final stage running as root, privileged services, a mounted Docker socket — then the warnings, and treat the infos as a checklist of defaults worth setting explicitly.
What can this audit not check?
Anything outside the pasted text: known vulnerabilities (CVEs) inside your base image and packages — that needs a scanner with a vulnerability database — the contents of your .dockerignore, build secrets passed with --secret (the safe pattern, which leaves no trace in the file), and how the container is actually run in production. This tool is the fast first pass over the two files that define the image and its runtime.