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.
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
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
dockerfile | body | string | yes | Dockerfile content (or a file upload / raw text body; max 500 KB). | |
strict | body|query | boolean | no | Also ask for digest-pinned base images. | |
ignore | body|query | string | no | Comma-separated rule ids to skip, e.g. healthcheck-missing,apt-pin. | |
min_severity | body|query | string | no | info | error, 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"}'const res = await fetch('https://apibox.io.vn/v1/dockerfile-lint', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"dockerfile": "FROM node:latest\nWORKDIR /app\nCOPY . .\nRUN npm install\nENV API_TOKEN=s3cr3t-value\nEXPOSE 3000\nCMD node server.js\n"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/dockerfile-lint",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"dockerfile": "FROM node:latest\nWORKDIR /app\nCOPY . .\nRUN npm install\nENV API_TOKEN=s3cr3t-value\nEXPOSE 3000\nCMD node server.js\n"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/dockerfile-lint');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"dockerfile":"FROM node:latest\\nWORKDIR /app\\nCOPY . .\\nRUN npm install\\nENV API_TOKEN=s3cr3t-value\\nEXPOSE 3000\\nCMD node server.js\\n"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));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
UUID Generator
Generate up to 1,000 UUID v4, time-ordered UUID v7, ULID, Nano ID or random hex IDs per request. Secure randomness, optional uppercase.
⏱Cron Expression Parser
Validate a cron expression and get its next run times in any timezone, with a plain-English description. Supports 5, 6 and 7-field cron syntax.
🕒Time & Timezone Converter
Get the current time in any timezone, convert between timezones and Unix timestamps (seconds or ms), with UTC offset and weekday for up to 30 zones.