Home
Dockerfile Linter

Dockerfile Security & Best Practices Linter

Audit Dockerfiles for security pitfalls, unpinned base images, root user execution, inefficient layer caching, and multi-stage build opportunities with 100% client-side analysis.

dockerfile linter onlinehadolint client webcis docker benchmark
F0/100
Security Score
Critical Pitfalls
17 findings require review
Critical & Errors
3
Root users, secrets, syntax
Warnings
5
Unpinned tags, cache bloat
Best Practices
9
Healthcheck, exec forms, ADD
Presets:
Detected Build Architecture (1 Stage - Single Stage)
⚠️ Single Stage
Stage 0: stage-0Final TargetL2
Base Image:node:latest
Pinned Tag:⚠️ Unpinned
User Security:Root (UID 0)
Dockerfile Editor(27 lines, 656 chars)
Live Linting
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Quick Snippets:
Audit Findings17 of 17
errorCIS-4.1security

Container Executes as Root User (UID 0)

The final production image does not specify a non-root USER instruction.

L2:Stage: stage-0 (node)
Why this matters:Containers running as root share kernel UID 0 with the host. Any container escape compromise grants full host root access.
Recommended Remediation:
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
errorSYNTAX-001syntax

Unknown Instruction

Unknown Dockerfile instruction. Verify command syntax and spelling.

L4:MAINTAINER devops@company.internal
Why this matters:The Docker daemon will fail to build the image due to unrecognized syntax errors.
errorDL4001security

Insecure Remote Script Piped to Shell

Piping curl or wget directly into shell ('curl ... | bash') is unsafe.

L18:RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
Why this matters:Executing untrusted remote scripts directly over the network bypasses integrity verification and can execute compromised code with root privileges.
Recommended Remediation:
# Download script, verify SHA256 checksum, then execute
warningDL3007security

Using ':latest' Base Image Tag

Avoid using ':latest' tag for base images in production Dockerfiles.

L2:FROM node:latest
Why this matters:The ':latest' tag mutates continuously upstream, risking sudden build breaks or untested security vulnerabilities.
Recommended Remediation:
FROM node:<exact-version>
warningPERF-MULTIperformance

Multi-Stage Build Opportunity Detected

Build toolchains and compilers detected inside a single-stage Dockerfile.

L2:FROM node
Why this matters:Single-stage builds bundle compiler tools, SDKs, and build caches directly into the production container image, inflating size by hundreds of megabytes.
Recommended Remediation:
# Convert to multi-stage: FROM base AS builder ... FROM runtime ... COPY --from=builder
warningDL3000best-practice

Relative WORKDIR Path

Use absolute paths for WORKDIR instructions instead of relative directory paths.

L10:WORKDIR app
Why this matters:Relative WORKDIR paths depend on previous state and can create unexpected nested folders.
Recommended Remediation:
WORKDIR /app
warningDL3009performance

Standalone 'apt-get update' Instruction

'apt-get update' should be chained in the same RUN layer with 'apt-get install'.

L16:RUN apt-get update
Why this matters:Separate RUN apt-get update instructions get cached independently by Docker, causing subsequent installs to fail or pull stale package references.
warningDL3008performance

Apt Package Cache Not Cleaned Up

Delete package lists ('rm -rf /var/lib/apt/lists/*') after apt-get install.

L17:RUN apt-get install -y curl git python3
Why this matters:Package index lists consume dozens of megabytes of unnecessary disk space inside production container images.
Recommended Remediation:
RUN apt-get install -y curl git python3 && rm -rf /var/lib/apt/lists/*
infoCIS-4.6best-practice

Missing HEALTHCHECK Instruction in Final Stage

No HEALTHCHECK instruction defined for container health monitoring.

L2:Stage: stage-0
Why this matters:Container orchestrators (Docker Swarm, Kubernetes, AWS ECS) use HEALTHCHECK to detect hung application processes and restart containers automatically.
Recommended Remediation:
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
  CMD curl -f http://localhost:8080/health || exit 1
infoDL3020best-practice

Use COPY Instead of ADD for Local Files

Use COPY rather than ADD when moving local files and folders into containers.

L13:ADD . .
Why this matters:ADD performs implicit tar archive extraction and remote URL fetching, introducing unexpected behaviors and container security vulnerabilities.
Recommended Remediation:
COPY . .
infoDL3015performance

Missing '--no-install-recommends' in apt-get

Add '--no-install-recommends' to prevent installing non-essential packages.

L17:RUN apt-get install -y curl git python3
Why this matters:Apt automatically installs recommended packages by default, inflating container image size with documentation, fonts, and auxiliary tools.
Recommended Remediation:
RUN apt-get install -y --no-install-recommends -y curl git python3
infoDL3059performance

Multiple Consecutive RUN Instructions

Consolidate consecutive RUN instructions using '&& ' to reduce image layers.

L17:RUN apt-get install -y curl git python3
Why this matters:Each RUN statement creates an independent read-only filesystem layer, causing storage bloat and slower container image pulls.
infoDL4006best-practice

Piped Command Without Shell 'pipefail' Option

Pipes in RUN instructions should enable pipefail.

L18:RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
Why this matters:Without 'set -o pipefail', a failure in the first command of a pipeline will be ignored, allowing failed builds to succeed silently.
Recommended Remediation:
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
infoDL3059performance

Multiple Consecutive RUN Instructions

Consolidate consecutive RUN instructions using '&& ' to reduce image layers.

L18:RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
Why this matters:Each RUN statement creates an independent read-only filesystem layer, causing storage bloat and slower container image pulls.
infoDL3059performance

Multiple Consecutive RUN Instructions

Consolidate consecutive RUN instructions using '&& ' to reduce image layers.

L20:RUN npm install
Why this matters:Each RUN statement creates an independent read-only filesystem layer, causing storage bloat and slower container image pulls.
infoSEC-003best-practice

Privileged Port (< 1024) Exposed

Exposed port is below 1024, traditionally requiring root privileges.

L23:EXPOSE 80
Why this matters:Binding privileged ports directly forces the process to require elevated capabilities. Prefer unprivileged ports like 8080, 8443, or 3000.
infoBEST-001best-practice

Shell Form Used for ENTRYPOINT

ENTRYPOINT uses shell syntax string instead of JSON exec array.

L26:CMD npm start
Why this matters:Shell form causes the container to run inside /bin/sh -c as PID 1, preventing POSIX signals (SIGTERM/SIGINT) from reaching your application process.
Recommended Remediation:
CMD ["npm","start"]

Export Dockerfile & CI/CD Audit Report

Download hardened configurations or copy standard Markdown reports for PR comments and security audits.

Zero-Knowledge Local Execution

All data processing, parsing, and compilation execute strictly inside your local browser memory. Zero external server uploads.

Instant Client-Side Engine

Instant real-time reactive computation delivers immediate feedback on every keystroke with zero network latency.

Production Standards & Compliance

Strictly validates syntax, edge cases, and formatting rules for dependable production output.

Technical Reference & Architecture Guide

Dockerfile Security & Best Practices Linter — Reference Guide

Audit Dockerfiles for security pitfalls, unpinned base images, root user execution, inefficient layer caching, and multi-stage build opportunities with 100% client-side analysis.

Dockerfile Security & Best Practices Linter — Reference Guide — Client-Side In-Memory Architecture & Data Flow
Dockerfile Security & Best Practices Linter — Reference Guide — Client-Side In-Memory Architecture & Data Flow

Key Parameters & Controls

Key Parameters & Controls
ParameterType / UnitDescriptionDefault
FROMdirectiveDefines the base image. Should include an explicit version tag or immutable SHA256 digest instead of ':latest'.Required
USERdirectiveSets the UID/GID for subsequent commands and container runtime. Should specify a non-root system user.Required (Security)
RUNdirectiveExecutes shell commands to install packages. Should combine package manager cleanup (e.g. apt-get clean) in the same layer.Optional
COPYdirectiveTransfers files from build context. Preferred over ADD for standard files; supports --chown flag.Optional

Pro Tips & Best Practices

Pin Images with SHA256 Digests

Use 'node:20-alpine@sha256:...' to guarantee immutable, reproducible builds that cannot be affected by upstream image changes.

Combine RUN Package Commands

Chain 'apt-get update && apt-get install -y --no-install-recommends pkg && rm -rf /var/lib/apt/lists/*' in a single RUN to prevent layer bloat.

Adopt Multi-Stage Builds

Compile code in an SDK container stage and copy only the final binary into a minimal distroless or alpine runtime stage.

Common Gotchas & Troubleshooting

⚠️Permission denied error in container when running as non-root USER

Use 'COPY --chown=appuser:appgroup' when transferring files into the image so the non-root user owns the working directory.

⚠️Docker build cache repeatedly invalidated on every commit

Copy package.json or dependency manifests first, run the dependency install step, and only copy the source code in later stages.

Frequently Asked Questions

Why should containers never run as the root user?▼

Running as root increases the blast radius of container breakouts. If an attacker breaches the application, they inherit root capabilities on the container and potentially the host kernel.

Why is the ':latest' tag considered harmful in production Dockerfiles?▼

The ':latest' tag is mutable and unpredictable. Builds executed across different days or environments can pull completely different OS versions and breaking dependency updates.

What is the difference between COPY and ADD?▼

COPY is predictable and only copies local files. ADD automatically unpacks tar archives and can fetch remote URLs, creating hidden security and caching risks.

How do multi-stage builds reduce image size and improve security?▼

Multi-stage builds leave compilers, SDKs, and build secrets behind in intermediate stages, keeping only the final executable in a tiny runtime container without shell or package tools.