Dockerfile Linter API

Lint a Dockerfile: unpinned or latest base images, root user, secrets in ENV / ARG, ADD URLs, apt / apk / pip cache, curl | sh, stage and syntax errors.

GETPOSThttps://apibox.io.vn/v1/dockerfile-lint
Developer utilities▶ Try it online

Send a Dockerfile (text, file or raw body) and get findings with line numbers, severity (error / warning / info), a short fix and a 0-100 score. The parser understands line continuations, the # escape= directive, BuildKit heredocs, JSON and shell forms and multi-stage builds.

Checks include: base image without tag or with :latest (digest pinning with strict=1), no USER or USER root in the final stage, literal secrets in ENV / ARG and known token formats anywhere, ADD from a URL without --checksum, ADD for local files, apt-get without -y, --no-install-recommends, update in the same layer or list cleanup, apk add without --no-cache, yum / dnf clean, pip --no-cache-dir, unpinned packages, npm install instead of npm ci, curl | sh, missing pipefail, cd instead of WORKDIR, sudo, chmod 777, COPY . . before installing dependencies (cache busting), several CMD / ENTRYPOINT, shell-form CMD, invalid EXPOSE, unknown or duplicate stage names in COPY --from, MAINTAINER, missing HEALTHCHECK.

Rules are our own (hadolint is GPL and is not used; there is no ShellCheck, so RUN scripts are checked heuristically). Filter with ignore (rule ids) and min_severity. The response lists the base images so you can check them with /v1/eol-check; Kubernetes manifests are validated by /v1/k8s-validate, CI workflows by /v1/ci-validate.

Markdown · OpenAPI · Postman · llms.txt

Parameters

NameInTypeRequiredDefault
dockerfilebodystringyesDockerfile content (or a file upload / raw text body; max 500 KB).
strictbody|querybooleannoAlso ask for digest-pinned base images.
ignorebody|querystringnoComma-separated rule ids to skip, e.g. healthcheck-missing,apt-pin.
min_severitybody|querystringnoinfoerror, warning or info.

Example

curl -X POST "https://apibox.io.vn/v1/dockerfile-lint" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"dockerfile":"FROM node:latest\nWORKDIR /app\nCOPY . .\nRUN npm install\nENV API_TOKEN=s3cr3t-value\nEXPOSE 3000\nCMD node server.js\n"}'

Response

{
  "valid": false,
  "errors": 1,
  "warnings": 2,
  "info": 4,
  "score": 71,
  "instructions": 7,
  "stages": [
    {
      "index": 0,
      "name": null,
      "base_image": "node:latest",
      "line": 1,
      "user": null
    }
  ],
  "base_images": [
    "node:latest"
  ],
  "findings": [
    {
      "rule": "from-latest",
      "severity": "warning",
      "line": 1,
      "message": "Base image \"node:latest\" uses :latest, which changes without notice; pin a version",
      "fix": "FROM node:<version>"
    },
    {
      "rule": "user-missing",
      "severity": "warning",
      "line": 1,
      "message": "The final stage has no USER: the container runs as root",
      "fix": "RUN useradd -r -u 10001 app (or adduser -D app on Alpine) and USER app before CMD"
    },
    {
      "rule": "healthcheck-missing",
      "severity": "info",
      "line": 1,
      "message": "No HEALTHCHECK in the final stage (fine on Kubernetes, which uses probes instead)"
    },
    {
      "rule": "copy-all-before-install",
      "severity": "info",
      "line": 3,
      "message": "COPY . before installing dependencies: every source change invalidates the dependency layer cache; copy the manifest / lockfile first, install, then copy the rest"
    },
    {
      "rule": "npm-ci",
      "severity": "info",
      "line": 4,
      "message": "Use npm ci (exact lockfile install) instead of npm install in images"
    },
    {
      "rule": "secret-in-env",
      "severity": "error",
      "line": 5,
      "message": "ENV API_TOKEN holds a literal secret: it is stored in the image layers / history",
      "fix": "Use a BuildKit secret: RUN --mount=type=secret,id=api_token …, or inject it at run time"
    },
    {
      "rule": "cmd-shell-form",
      "severity": "info",
      "line": 7,
      "message": "CMD in shell form runs under /bin/sh -c: the process is not PID 1 and does not receive SIGTERM; use the JSON (exec) form",
      "fix": "CMD [\"node\",\"server.js\"]"
    }
  ],
  "note": "Own rules (no hadolint / ShellCheck code). Check base images for end-of-life with /v1/eol-check and Kubernetes manifests with /v1/k8s-validate."
}

Use cases

  • Fail a CI job when a Dockerfile runs as root or leaks a secret
  • Review Dockerfiles in pull requests from a bot
  • Teach teams image best practices with concrete fixes
  • Audit the Dockerfiles of many repositories in bulk

FAQ

Is this hadolint?

No. The rules are written from scratch (hadolint is GPL-3.0); they cover the most common hadolint-style checks plus secrets and cache-order hints.

Are RUN scripts analysed?

With heuristics for package managers, downloads, pipes, cd, sudo and permissions; there is no full shell analysis (ShellCheck).

Can I silence a rule?

Yes: pass rule ids in ignore (comma-separated) or raise min_severity to warning or error.

Related APIs

Start with 1,000 free requests every month. Get free API key →