2ClickKit

Dockerfile Linter & Security Validator

Files Never Leave Your Device

Static analysis linter for Dockerfiles: detect root execution vulnerabilities, unpinned image tags, package cache bloat, and layer inefficiencies right in your browser.

Dockerfile Linter & Security Validator

Inspect Dockerfiles for root execution, unpinned tags, layer bloat, and security flaws.

100% In-Browser · Private & Secure
Load Template:
Security & Hygiene Score:0/100
3 Errors 6 Warnings 3 Suggestions
Dockerfile Editor
Linter Findings (12)
WARNINGLine 2 [FROM]DL3007-unpinned-tag

Base image "node:latest" uses untagged or ":latest" version tag.

Remediation: Pin your base image to a specific immutable semantic version (e.g. node:20.11-alpine).
ERRORLine 4 [ENV]SEC-001-hardcoded-secret

Potential hardcoded sensitive credential detected matching "password".

Remediation: Never bake secrets into container images. Inject secrets at runtime via Docker secrets or env files.
ERRORLine 5 [ENV]SEC-001-hardcoded-secret

Potential hardcoded sensitive credential detected matching "api_key".

Remediation: Never bake secrets into container images. Inject secrets at runtime via Docker secrets or env files.
WARNINGLine 11 [RUN]DL3009-apt-update-alone

"apt-get update" should always be chained with "apt-get install" in the same instruction.

Remediation: Combine apt-get update && apt-get install -y ... to prevent Docker cache drift.
INFOLine 12 [RUN]DL3008-clean-apt-lists

Package cache lists are not removed after apt-get install.

Remediation: Append "&& rm -rf /var/lib/apt/lists/*" to shrink the resulting image size by 30-50MB.
WARNINGLine 13 [RUN]DL3059-chain-run

Multiple consecutive RUN instructions detected (3 in a row).

Remediation: Chain consecutive RUN commands using && to reduce intermediate Docker image layers.
INFOLine 13 [RUN]NODE-001-prefer-npm-ci

Consider using "npm ci" instead of "npm install" in automated Docker builds.

Remediation: "npm ci" strictly adheres to package-lock.json and guarantees reproducible deterministic builds.
WARNINGLine 15 [ADD]DL3010-remote-add

Using ADD to download remote HTTP URLs creates permanent uncacheable layers.

Remediation: Use curl/wget inside a RUN instruction and clean up temporary downloads in the same layer.
ERRORLine 17 [EXPOSE]DL3011-invalid-port

Port "99999" is not a valid TCP/UDP port number (must be 1-65535).

Remediation: Specify a standard valid port such as 80, 443, 3000, 8080.
WARNINGLine 20 [CMD]DL4003-multiple-cmd

Multiple CMD instructions declared. Only the last CMD instruction takes effect.

Remediation: Remove redundant CMD instructions and keep only the primary container entry command.
WARNINGLine 21 [USER]SEC-002-missing-user

No non-root USER instruction specified. The container will run with root privileges.

Remediation: Declare USER <non-root-user> before CMD or ENTRYPOINT to prevent root container escapes.
INFOLine 21 [HEALTHCHECK]OPS-001-missing-healthcheck

No HEALTHCHECK instruction declared.

Remediation: Add a HEALTHCHECK instruction so Docker and orchestration engines can monitor container readiness.

Container Security Architecture and Dockerfile Hygiene

Containerization with Docker and Open Container Initiative (OCI) images revolutionized software deployment by encapsulating application code, runtime dependencies, system binaries, and configuration files into portable, immutable artifacts. However, an image is only as secure and performant as the instructions defined in its Dockerfile.

In production enterprise environments, flawed Dockerfiles represent a substantial attack surface. Antipatterns such as running unprivileged web applications as root, baking hardcoded secrets into image layers, neglecting package manager cleanup, and failing to define health check boundaries frequently lead to severe security incidents, deployment instability, and massive storage costs in container registries.

The Anatomy of Docker Image Layers and the Union File System

Docker images are composed of stacked, read-only filesystem layers managed by storage drivers such as Overlay2. Each directive in a Dockerfile (particularly RUN, COPY, and ADD) creates a discrete cryptographic layer:

The Layer Immutability Principle

Deleting a file in a subsequent RUN instruction does not reduce the image size! The file remains permanently recorded in the preceding layer's delta. For example:

RUN wget https://example.com/big-archive.tar.gz && tar -xf big-archive.tar.gz
RUN rm big-archive.tar.gz

In the example above, the archive consumes space in Layer #1 forever. To minimize image weight, downloads, extraction, compilation, and cleanup must be executed within a single chained instruction:

RUN wget -qO- https://example.com/big-archive.tar.gz | tar -xz && rm -rf /tmp/*

Essential Linter Rules and Security Directives Matrix

2ClickKit evaluates your Dockerfile against established industry standards adapted from Hadolint, CIS Docker Benchmarks, and NIST SP 800-190 (Application Container Security Guide):

Rule ID Directive Severity Rationale & Impact
DL3006 / DL3007 FROM Warning Unpinned or :latest base image tags cause non-deterministic builds and break reproducibility.
SEC-002 / DL3002 USER Critical Error Containers running as root (UID 0) expose the underlying host kernel to privilege escalation attacks.
SEC-001 ENV Critical Error Hardcoding credentials in ENV exposes secrets via docker inspect and registry layers.
DL3008 / DL3009 RUN apt-get Warning Unchained package installations cause cache drift; omitting cache cleanup wastes 30–100MB of layer disk space.
DL3020 ADD vs COPY Warning ADD has ambiguous side effects (auto-tar extraction). COPY is explicit and safer.
DL4003 / DL4004 CMD / ENTRYPOINT Warning Multiple declarations override earlier ones, resulting in dead code and confusing execution intent.
OPS-001 HEALTHCHECK Info Missing health probes prevents orchestrators (Docker Swarm / Kubernetes) from detecting deadlocks.

Multi-Stage Builds: The Gold Standard of Production Packaging

The single most effective architectural pattern for optimizing container security and size is the Multi-Stage Build. Traditional Dockerfiles bundled compilers, SDKs, development headers (such as gcc, python3-dev, or full Node.js toolchains), and test suites directly into the production container. This inflated image sizes to several gigabytes and introduced thousands of unnecessary CVE vulnerabilities.

Multi-stage builds split the pipeline into an isolated compilation stage and a lean runtime stage:

# Stage 1: Build & Compile in heavy SDK environment
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Stage 2: Distroless / Minimal Runtime
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
COPY --from=builder --chown=appuser:appgroup /app/dist ./dist
COPY --from=builder --chown=appuser:appgroup /app/node_modules ./node_modules
USER appuser
EXPOSE 3000
HEALTHCHECK --interval=30s CMD wget -qO- http://localhost:3000/health || exit 1
CMD ["node", "dist/server.js"]

By transferring only the compiled distribution bundle (dist/) and production dependencies into the second stage, developers achieve:

  • Up to 90% Image Size Reduction: Eliminating compilers, source code files, and build caches.
  • Minimal Attack Surface: Package managers (like npm or pip) and shell interpreters can be entirely stripped in distroless runtime containers.
  • Non-Root Execution: Explicitly assigning an unprivileged user (appuser) prevents container breakouts.

Handling Secrets Without Leaking Layers

A common developer mistake is attempting to inject private repository tokens, database passwords, or SSH keys via ARG or ENV:

Security Warning: Arguments and Environment Variables

Any value passed via ARG or ENV is stored in plain text inside the image manifest. Anyone with access to the container image can inspect these secrets simply by running docker history --no-trunc <image>.

To securely supply secrets during build time without baking them into layers, leverage BuildKit's secret mount syntax:

# BuildKit secret mounting syntax (zero layer leakage)
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci

Zero-Server In-Browser Static Analysis Guarantee

Security audit regulations frequently prevent engineering teams from uploading internal Dockerfiles, enterprise repository URLs, or infrastructure manifests to public web services. 2ClickKit performs all lexical tokenization, regex matching, and severity scoring 100% inside your client-side browser runtime. No source code or Docker metadata is ever transmitted over the network.

How to Use Dockerfile Linter & Security Validator

  1. Paste or Load Dockerfile

    Paste your raw Dockerfile into the interactive editor or pick one of our pre-configured templates (Node.js, Python, Go, or Flawed Test).

  2. Real-Time Static AST Rule Evaluation

    Our browser engine parses instructions line-by-line, validating base image tags, security policies, and package management best practices.

  3. Review Categorized Findings

    Examine detailed findings broken down into Errors (critical security flaws), Warnings (layer bloat/caching issues), and Suggestions.

  4. Implement Recommended Remediations

    Follow the specific code refactoring advice, such as pinning image digests, chaining RUN instructions, and enforcing non-root USER directives.

  5. Copy Hardened Dockerfile

    Export your optimized, production-grade Dockerfile ready for CI/CD container builds and Kubernetes deployment.

Security Remediation Example

Insecure Directive
FROM node:latest
ENV SECRET_KEY=12345
RUN apt-get update
CMD ["npm", "start"]
Lint Findings
1 Critical (ENV Secret), 2 Warnings (Untagged :latest, Missing non-root USER), 1 Suggestion (Unchained apt-get)

Calculates hygiene score and provides drop-in hardened code snippet.

Technical Specifications

  • Supported Inputs: Standard Dockerfile, Multi-Stage OCI Container Files, Containerfile (Podman)
  • Input Limit: Unlimited (in-memory parsing)
  • Processing Engine: 100% In-Browser (Client-side AST and Rule Engine)
  • Content Uploads: None (Your files and text are processed locally on your device with zero uploads)

Privacy & Security Guarantee

Your Dockerfile text instructions and build configurations are processed entirely in your web browser's memory using native client-side web technologies. Unlike traditional cloud tools, your content is never uploaded to remote servers, stored on external disks, or analyzed by third parties.

2ClickKit In-Browser vs Traditional Cloud Tools

Feature 2ClickKit (In-Browser) Traditional Cloud Services
Data Privacy Files never leave your local device Uploaded to remote servers and third-party clouds
Processing Speed Instant local execution (0ms upload time) Constrained by internet upload & server processing queues
Account & Costs 100% Free with zero registration or paywalls Tiered subscriptions, limits, or forced sign-ups

Frequently Asked Questions

Why is running container processes as root considered dangerous?

By default, Docker containers run all processes as the root user (UID 0). Because Linux container isolation relies on shared kernel namespaces and cgroups rather than hardware virtualization, a vulnerability in the application runtime or a container breakout flaw could grant an attacker root access to the underlying host node. Declaring a dedicated non-root USER instruction limits the blast radius of remote code execution exploits.

Why should I never use the :latest tag on Docker base images?

The ':latest' tag is a mutable pointer that updates whenever an upstream vendor pushes a new build. Relying on ':latest' breaks build reproducibility, causing identical Dockerfiles to produce different binaries over time. Additionally, automatic upstream updates can introduce breaking API changes, deprecated libraries, or untested security vulnerabilities without developer oversight.

Why must 'apt-get update' and 'apt-get install' be chained in a single RUN?

Docker caches each build instruction as an intermediate layer. If 'apt-get update' is placed in its own RUN instruction, Docker will reuse that cached package index layer during future builds even when upstream repositories have updated. Chaining 'apt-get update && apt-get install -y --no-install-recommends ... && rm -rf /var/lib/apt/lists/*' guarantees fresh packages and strips temporary index archives to minimize image size.

What is the primary difference between ADD and COPY in Dockerfiles?

COPY is the preferred instruction for copying local files and directories into the container image. ADD has additional implicit behaviors: it automatically extracts local tar archives (.tar, .tar.gz) into the destination directory and supports downloading remote URLs. However, downloading URLs via ADD creates uncacheable image bloat; using curl or wget inside a chained RUN instruction allows temporary archives to be deleted in the same layer.

What happens when multiple CMD or ENTRYPOINT instructions exist in a Dockerfile?

Only the last CMD or ENTRYPOINT instruction in a Dockerfile takes effect. Any preceding CMD or ENTRYPOINT statements are completely overridden. Declaring multiple CMD directives usually indicates developer confusion between build-time instructions and runtime commands.

Is my proprietary Dockerfile uploaded to an external server for analysis?

No. The linter executes 100% inside your browser using client-side JavaScript AST tokenization. Your infrastructure configurations, internal base images, application architectures, and environment variable names never leave your computer.