Dockerfile Linter
Lint, validate, format, and optimize Dockerfiles with Hadolint-compatible rules, security checks, and multi-stage analysis.
Write production-ready, secure, and minimal Docker containers. This browser-based Dockerfile linter analyzes your Dockerfiles across multiple dimensions: Hadolint-compatible best practice rules (DL3000–DL4006), security vulnerability checks (hardcoded secrets in ENV/ARG, root user risks, permissive chmod 777), image layer caching efficiency, unpinned package installation warnings (apt, apk, npm, pip), deprecated MAINTAINER detection, and multi-stage build optimization recommendations. Get line-level severity annotations, an automated container health score, and instant formatting. Your Dockerfile is parsed and linted entirely client-side — your code and secrets never leave your browser.
Keywords: dockerfile linter, dockerfile validator, docker linter online, dockerfile best practices, hadolint online, dockerfile security checker, dockerfile syntax checker, dockerfile optimizer, dockerfile lint online, docker build linter, dockerfile multi-stage checker, docker container linter, online dockerfile checker, dockerfile health score, dockerfile analyzer, hadolint web, dockerfile formatter
Tags: dockerfile, docker, lint, validate, container, devops, security, hadolint
Popular Developer Tools tools
- JWT DecoderDecode, inspect, and validate JWT tokens with claim and signature analysis.
- Cron ParserParse, validate, explain, and build cron expressions with next run times and visual timeline.
- Regex TesterTest, debug, and explain regular expressions with real-time match highlighting.
- Regex ExplainerBreak down any regex into plain English, token by token.
- JSON to TypeScript & Schema GeneratorGenerate TypeScript interfaces, Zod schemas, and Valibot schemas from JSON.
Dockerfile Linter is also known as: Dockerfile Validator, Online Hadolint, Docker Container Linter, Dockerfile Best Practices Checker, Dockerfile Security Scanner, Multi-Stage Dockerfile Optimizer, Docker Build Linter Online, Hadolint Web Linter.
How to Dockerfile Linter Online
Paste your Dockerfile content directly into the input editor, upload an existing Dockerfile from your filesystem, or choose one of the pre-configured production templates (Node.js multi-stage, Python FastAPI, Go scratch, or anti-pattern example) from the dropdown.
Customize your linting checks using the bottom options bar: toggle Security Audits (hardcoded credentials, root user, sudo), Best Practice Rules (Hadolint DL-series), Style Guidelines (keyword casing, clean formatting), and Layer Optimizations (cache ordering, layer chaining).
Review the instant linting diagnostics rendered in real time. Issues are organized by severity (Error, Warning, Info, Style, and Security) with precise line-number annotations, explanatory diagnostics, and clickable links to official Hadolint rule documentation.
Inspect your Container Health Score (0–100) and Stage Overview cards to review base images, stage aliases (AS <name>), declared user privileges, and working directories across single-stage and multi-stage builds.
Click the Format tab (⌘⇧F) to automatically clean up whitespace and standardize instruction keywords to uppercase, or click the Summary tab (⌘⇧S) for an architectural breakdown of exposed ports, volumes, entrypoints, and health checks.
Switch to the Optimize tab (⌘⇧O) to receive actionable recommendations for improving Docker build cache utilization, eliminating redundant package manager cache layers, and minimizing production image size.
Copy your validated, clean Dockerfile to your clipboard (⌘⇧C) or download it directly for use in your local development environment, Docker Compose configurations, or CI/CD automated deployment pipelines.
Dockerfile Linter Features
Comprehensive Hadolint Compatibility: Implements standard Hadolint DL-series rules (DL3000 through DL4006) directly in the browser with full AST-based parsing and zero external CLI dependencies.
Security Vulnerability Detection: Scans Dockerfiles for critical security anti-patterns including hardcoded secrets/API keys in ENV and ARG directives (SC1000/SC1001), insecure root user execution (DL3002), dangerous sudo usage (DL3004), and overly permissive file permissions (chmod 777).
Intelligent Build Cache & Layer Optimization: Analyzes instruction ordering to flag cache-busting patterns like `COPY . .` before dependency installations (OP1002) and unchained consecutive RUN statements that create bloated intermediate layers (OP1000).
Multi-Stage Build Architectural Analysis: Identifies orphaned or unused build stages (OP1001), ensures proper `COPY --from` references, and checks that non-root users and minimal runtime artifacts are properly configured in final production stages.
Package Manager Best Practices: Validates package management across major Linux distributions including Debian/Ubuntu (`apt-get install` version pinning, `-y` flag, `--no-install-recommends`, and `/var/lib/apt/lists/*` cleanup), Alpine Linux (`apk add --no-cache`), Python (`pip install` version pinning/requirements.txt), and Node.js (`npm ci` vs `npm install`).
Exec vs Shell Form Validation: Enforces POSIX-compliant JSON exec array syntax for CMD and ENTRYPOINT directives (DL3025) to guarantee proper Unix signal forwarding (SIGTERM, SIGINT) for graceful container shutdown.
Automated Container Health Scoring: Computes a weighted 0–100 Container Quality Score giving you an instant benchmark of your Dockerfile readiness for production environments.
Deterministic Base Image Verification: Detects unpinned `FROM` instructions and warns against mutable `:latest` tags (DL3006/DL3007) that cause non-reproducible container builds and unexpected deployment failures.
Real-Time Live Linting with Keyboard Navigation: Powered by debounced background AST analysis with native keyboard shortcuts: ⌘↵ (Run), ⌘⇧V (Lint), ⌘⇧F (Format), ⌘⇧S (Summary), and ⌘⇧O (Optimize).
100% Client-Side Privacy Guarantee: All Abstract Syntax Tree (AST) parsing and rule evaluation occurs entirely in your local browser runtime. Sensitive credentials, internal service names, and proprietary source layouts never leave your machine.
REST API Integration: Programmatically lint, format, and audit Dockerfiles via the `/api/tools/dockerfile-linter` REST endpoint for easy integration into pre-commit hooks, developer scripts, and CI/CD validation steps.
In-Depth Technical Guides
All GuidesDockerfile Best Practices: Layer Caching, Multi-Stage Builds & Security Hardening
A comprehensive developer guide to writing production-grade Dockerfiles: mastering BuildKit cache invalidation, multi-stage builds, non-root execution, and security linting.
Kubernetes YAML Validation: The 10 Most Common Manifest Mistakes
Diagnose and fix syntax errors, missing resource limits, selector mismatches, and schema validation failures in Kubernetes manifests before deployment.
Migrating from Docker Compose to Kubernetes: Complete Translation Guide
Translate Docker Compose stacks into production-ready Kubernetes manifests. Map services to Deployments, host volumes to PVCs, and env files to ConfigMaps.
Related Standards & RFC Specifications
All StandardsDocker Compose is a declarative tool for defining and running multi-container Docker applications using standardized YAML service definitions.
A Dockerfile is a declarative text document containing sequential instructions used by the Docker daemon or BuildKit engine to automate container image builds.
Dotenv is a key-value configuration file convention standardized by the Twelve-Factor App methodology for injecting environment variables into application runtimes.
GitHub Actions is a declarative continuous integration and continuous delivery (CI/CD) platform integrated into GitHub that enables automated testing, building, linting, and deployment via YAML workflows.
The Open Container Initiative (OCI) is an open governance project that defines standardized specifications for container runtime formats and container image formats.
An SBOM is a formal, machine-readable inventory of software components, dependencies, libraries, and licenses that comprise a software build.
Explore Full AI Model Pricing Directory
Compare per-token rates, prompt caching discounts, and context windows across leading LLMs (GPT-4o, Claude 3.5 Sonnet, Gemini 2.5 Flash, DeepSeek, and more) in our verified catalog.
Pre-built Automation Pipelines
Chain Dockerfile Linter with other utilities in a multi-step visual workflow.
Base64 Decode → JSON Format
Decode a Base64 string and pretty-print the JSON inside it.
CSV → JSON → YAML
Convert CSV data to JSON, then to YAML format.
JSON Format → TypeScript Schema
Format JSON and generate TypeScript/Zod schema from it.
Example Input & Output
Sample ReferenceInteractive Example: Dockerfile Linter in ActionShow example
Sample Input (dockerfile)
FROM node:latest
WORKDIR /app
COPY . .
RUN npm install
CMD ["npm", "start"]Sample Output
[WARNING] Line 1: Use specific image digests or semantic versions rather than ':latest'.
[WARNING] Line 4: Separate package installation from source code COPY to leverage build layer caching.
[RECOMMENDATION]: Run as non-root user (USER node).What happened:
Scans Dockerfiles against Hadolint guidelines and production container security rules.
Error Diagnostics & Triage Guides
All Debug GuidesERROR: failed to solve: failed to compute cache key: not found
BuildKit cannot find the file or directory specified in a COPY or ADD instruction relative to the build context. This occurs when relative paths are incorrect or the file is inadvertently ignored in .dockerignore.
permission denied while trying to connect to the Docker daemon socket
The current non-root user lacks read/write permissions to `/var/run/docker.sock`. By default, only the root user and members of the `docker` user group can access the Docker engine socket.
Frequently Asked Questions
- What is a Dockerfile Linter and why is it important?
- A Dockerfile linter is a static analysis tool that parses your Dockerfile into an Abstract Syntax Tree (AST) and evaluates it against industry best practices, security standards, and performance guidelines. Linting Dockerfiles before building images helps eliminate security vulnerabilities (such as leaked credentials and root execution), shrinks image file sizes, speeds up build times through efficient layer caching, and ensures reproducible deployments across development and production environments.
- Is this Dockerfile linter compatible with Hadolint?
- Yes. This linter implements Hadolint-compatible rule IDs (such as DL3000, DL3002, DL3003, DL3004, DL3006, DL3007, DL3008, DL3009, DL3013, DL3014, DL3015, DL3016, DL3018, DL3019, DL3020, DL3025, DL3027, DL4000, DL4003, DL4004, and DL4006). Each rule provides direct links to the official Hadolint documentation so you can understand the exact reasoning and remediation for every warning.
- Why should I avoid using the :latest tag in FROM instructions (DL3007)?
- The `:latest` tag is mutable and points to whatever image version the repository maintainer most recently published. When building from `:latest`, your builds become non-deterministic: a build today may succeed while the same build tomorrow might break due to upstream dependency or OS changes. For predictable, reproducible container builds, always pin explicit version tags (such as `node:20.18-alpine` or `python:3.11-slim`) or immutable image SHA digests.
- Why should containers not run as the root user (DL3002)?
- By default, Docker containers run processes as the root user (UID 0). If an attacker manages to exploit a vulnerability in your application and escape the container runtime, they gain root privileges on the underlying host kernel. Creating and declaring a dedicated non-root user (e.g. `USER node` or `USER 10001:10001`) enforces the principle of least privilege and significantly limits the blast radius of container security incidents.
- Why is `COPY . .` before `RUN npm install` or `pip install` bad for caching (OP1002)?
- Docker evaluates cache validity sequentially from top to bottom. If you copy your entire project directory with `COPY . .` before running package manager installations, modifying any single file (such as a README or frontend component) invalidates Docker’s cache for that step and all subsequent steps. This forces package managers to re-download all dependencies from scratch. The recommended pattern is to copy only dependency manifests first (e.g. `COPY package*.json ./` or `COPY requirements.txt .`), run the install step, and only then copy the remaining source code.
- What is the difference between `COPY` and `ADD` instructions in Dockerfiles (DL3020)?
- `COPY` is the preferred instruction for copying local files and directories into a container because it is explicit and transparent. `ADD` includes implicit magic behaviors: it can automatically extract recognized compressed archives (.tar, .tar.gz, .zip) into the destination directory and download files directly from remote URLs. Using `ADD` for standard file copying creates ambiguity and risks unexpected build behaviors. Use `COPY` for all standard files, and reserve `ADD` strictly for local tarball auto-extraction.
- Why should CMD and ENTRYPOINT use JSON exec array format instead of shell format (DL3025)?
- When you define `CMD node server.js` (shell form), Docker wraps your command inside a shell subprocess (`/bin/sh -c "node server.js"`). Because the shell process receives PID 1 inside the container rather than your application, standard POSIX termination signals (like `SIGTERM` and `SIGINT`) sent by `docker stop` or Kubernetes during pod shutdown are not forwarded to your app. This causes unclean shutdowns and connection drops until Docker issues a forceful `SIGKILL`. Using exec form (`CMD ["node", "server.js"]`) runs your application as PID 1, allowing graceful shutdown handlers to execute cleanly.
- How do multi-stage builds help optimize container size?
- Multi-stage Docker builds allow you to use separate `FROM` stages for compiling and runtime packaging. You can install heavy build tools, compilers (like GCC, Go, Rust), development headers, and build dependencies in an initial `builder` stage, and then copy only the compiled binary or production bundle into a clean, minimal runtime image (like `alpine`, `distroless`, or `scratch`). This prevents build tools and source code from bloating the final production image and reducing the attack surface.
- Why should I clean package manager caches in the same RUN layer (DL3009/DL3019)?
- Each `RUN` instruction in a Dockerfile creates an immutable filesystem layer. If you execute `RUN apt-get update && apt-get install -y curl` in one step and run `RUN rm -rf /var/lib/apt/lists/*` in a separate later step, the cached package list files are still stored permanently in the earlier intermediate layer and remain part of the total image download size. Always chain package installation and cache cleanup in a single `RUN` instruction using `&&` (e.g. `RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*`).
- What is the purpose of the HEALTHCHECK instruction in Dockerfiles (SC1003)?
- The `HEALTHCHECK` directive instructs Docker and container orchestrators (like Kubernetes or Docker Swarm) on how to test that the containerized process is genuinely healthy and responsive, not merely running. If a web service deadlocks or enters a zombie state while the process PID is still alive, a configured health check (e.g. `HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:8080/health || exit 1`) detects the failure and allows orchestrators to automatically restart or re-route traffic away from the unhealthy container.
- What is the difference between ARG and ENV directives in Dockerfiles (SC1000/SC1001)?
- `ARG` variables exist exclusively during the image build phase (accessible via `docker build --build-arg`) and are not available when the container runs unless explicitly assigned to an `ENV` variable. In contrast, `ENV` variables persist into intermediate layers and remain active in the running container environment. However, neither `ARG` nor `ENV` should ever be used to pass sensitive API keys or passwords, as both are permanently recorded in the image layer history visible via `docker history` and `docker inspect`. For private build dependencies, use BuildKit secret mounts (`RUN --mount=type=secret`).
- How does BuildKit improve Dockerfile performance compared to legacy Docker builders?
- BuildKit (enabled with `# syntax=docker/dockerfile:1` or `DOCKER_BUILDKIT=1`) introduces a next-generation graph-based execution engine that analyzes Dockerfile Abstract Syntax Trees (ASTs) for parallel stage compilation. Independent build stages in multi-stage builds execute concurrently rather than sequentially. BuildKit also supports advanced features like persistent package cache mounts (`RUN --mount=type=cache`), secure secrets mounting without layer persistence (`--mount=type=secret`), SSH forwarding (`--mount=type=ssh`), multi-line Heredocs (`RUN <<EOF`), and fast incremental layer hashing.
- Is my Dockerfile or source code sent to any remote server?
- No. This tool is built with a zero-trust, privacy-first design. All parsing, AST traversal, rule evaluation, and formatting logic runs entirely client-side inside your web browser. Your Dockerfiles, internal hostnames, port mappings, and build scripts never leave your machine.
- Can I integrate this Dockerfile linter into our CI/CD workflow?
- Yes. You can use the `/api/tools/dockerfile-linter` REST API endpoint via `curl`, Python, or GitHub Actions to lint Dockerfiles programmatically during CI checks. The endpoint returns structured JSON output containing rule IDs, severities, exact line numbers, and actionable fix suggestions.
Related Developer Tools
- Docker Compose to KubernetesConvert docker-compose.yml to Kubernetes Deployment, Service, ConfigMap, and PVC manifests.
- Kubernetes YAML ValidatorValidate, lint, and format Kubernetes manifests against structure rules, deprecated APIs, and security best practices.
- GitHub Actions ValidatorValidate, format and summarize GitHub Actions workflow YAML files against official schemas.
- Env File Parser & ConverterParse, validate, and convert .env files between JSON, YAML, Docker, and Kubernetes formats.
- Prompt Injection & Secret ScannerScan prompts, code, and text for prompt injection patterns, secret leaks, unsafe instructions, and PII exposure.
- Git Conflict ResolverVisually resolve Git merge conflicts by picking current, incoming, or both versions.
- YAML ConverterConvert between JSON and YAML with validation, formatting, and multi-document support.
- Text Diff CheckerCompare two text blocks and highlight exactly what changed.