Skip to main content

DockRx

Python 3.12+ License: Apache-2.0 Tests Status

Analyze Dockerfiles and explain performance, size, caching, and security problems with actionable fixes.

DockRx is built to answer one question well:

How do I improve this Dockerfile?

Instead of stopping at lint-style warnings, DockRx explains impact, prioritizes quick wins, shows copy-paste fixes, and helps you compare before/after improvements.

Try it now — no install required: dockrx.vercel.app is a live web playground where you can paste a Dockerfile and get an instant health report. The CLI adds fix/compare/badge/format and project-context checks.

DockRx demo

Alpha note: image-size and build-time numbers in the report are heuristic estimates, not measured from real builds. dockrx fix / suggest auto-fix a subset of rules; others are recommendations only.

Real Example

$ dockrx analyze examples/test

Overall Health
█████████░░░░░░░░░░░
47 / 100
Needs Attention · Grade: F (Poor)

Quick Wins
1. Switch JDK -> JRE runtime          ↓ ~100-300 MB   2 min
2. Add .dockerignore                  ↑ 20-70%        30 sec
3. Remove debug networking tools      ↓ ~15-80 MB     1 min

Estimated Results
↓ ~247 MB image size
↑ ~45% faster builds
↓ 2 security risks

Why DockRx

  • diagnosis-oriented output, not just warnings
  • rule explanations via dockrx explain
  • non-destructive fix previews via dockrx fix (writes Dockerfile.fixed)
  • before/after comparison via dockrx compare
  • extensible hybrid rule engine for teams

Install

git clone https://github.com/kiwi-07/docrx.git
cd docrx
uv sync
uv run dockrx --version

Naming note: the GitHub repo is docrx, but the installed CLI and Python package are dockrx. Clone into docrx, run the tool as dockrx.

From PyPI

dockrx is published on PyPI:

pip install dockrx
# or
pipx install dockrx
# or run without installing:
uvx --from dockrx dockrx --version

Commands

dockrx analyze .
dockrx analyze Dockerfile
dockrx analyze . --json
dockrx analyze . --score-only

dockrx explain DRX018

dockrx fix . --dry-run --yes
dockrx fix . --yes
dockrx fix . --limit 5

dockrx compare before/ after/
dockrx compare before/ after/ --json

dockrx badge . --format markdown
dockrx suggest . --yes
dockrx format Dockerfile --check

dockrx --version

Full command reference: docs/commands.md

How DockRx Compares to Hadolint

Capability DockRx Hadolint
Dockerfile linting Yes Yes
Explain impact (size, cache, hardening) Yes Limited
ROI-prioritized output Yes No
Suggested fixes in output Yes Limited
Rule knowledge base (explain) Yes No
Non-destructive fix preview Yes No
Before/after comparison Yes No
Shell linting inside RUN Limited Strong
Mature production ecosystem Early-stage Very mature

DockRx is not trying to replace Hadolint. Today the best pairing is:

  • Hadolint for deep Dockerfile + shell linting
  • DockRx for optimization, prioritization, explainability, fixes, and team-facing UX

DockRx is also not a CVE/vulnerability scanner.

Features

  • Hybrid rule engine: built-in YAML rules + Python plugins
  • Rich terminal diagnosis with health gauge, quick wins, lost points, estimated results, treatment plan
  • dockrx explain rule documentation
  • dockrx fix / suggest — non-destructive rewrite to Dockerfile.fixed (subset of rules)
  • dockrx compare before/after Dockerfile comparison
  • dockrx badge health-grade SVG/markdown badges
  • dockrx format Dockerfile formatter (--check / --diff safe; --write overwrites in place)
  • JSON output for CI or automation
  • Project-local rule and plugin overrides
  • Configurable via [tool.dockrx] in pyproject.toml

Built-in Rule Coverage

DockRx ships with built-in YAML rules and Python plugins covering:

  • cache ordering for npm, pip, Maven, Gradle, Go, and Cargo
  • package manager cache cleanup (apt, apk, pip, npm)
  • runtime hardening (USER, secrets in ENV, debug tools in runtime)
  • image-size reductions (JDK in runtime, large base images, build tools in final stage)
  • best practices (HEALTHCHECK, LABEL, .dockerignore, ADD vs COPY)

Configuration

Optional settings in your project's pyproject.toml:

[tool.dockrx]
log-level = "WARNING"
fail-on-severity = "HIGH"          # analyze exit 1 threshold: HIGH|MEDIUM|LOW|INFO|none
default-fix-limit = 3
health-thresholds = { excellent = 90, good = 75, fair = 60, needs-attention = 40 }

JSON Output

dockrx analyze . --json
dockrx compare before/ after/ --json

Roadmap

Now

  • static Dockerfile analysis
  • rich terminal UX
  • explain / fix / compare / badge / suggest / format
  • GitHub Action + local extensibility

Next

  • image inspection / layer-size analysis
  • richer auto-fix coverage
  • CLI helpers to scaffold local rules

Later

  • HTML reports
  • remote rule packs
  • VS Code extension

Full roadmap: docs/roadmap.md

Documentation

Development

uv sync --group dev
uv run pytest
uv run ruff check src/ tests/
uv run dockrx analyze examples/bad
uv run dockrx analyze examples/good
uv run dockrx compare examples/bad examples/good
uv run dockrx fix examples/test --dry-run --yes

License

Apache-2.0

Metadata

Release files for dockrx 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dockrx 0.1.1
File Size Uploaded Provenance
dockrx-0.1.1.tar.gz 50.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dockrx 0.1.1
File Interpreter ABI Platform
dockrx-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 124.8 kB

Release files / dockrx-0.1.1.tar.gz

Download URL dockrx-0.1.1.tar.gz
Size 50.1 kB
Tags Source
SHA-256 checksum
How to use checksums
160ebfa4ed7e2dfdf3afe9d73e312e5501798b4add8a7827d8657f7704bdb04a
BLAKE2b-256 checksum
How to use checksums
d9a77615ead60c1ebccbd9e3af5eab20151c6a688984db8f041363addf0762ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / dockrx-0.1.1-py3-none-any.whl

Download URL dockrx-0.1.1-py3-none-any.whl
Size 74.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69e2c26ac558b90803690dcf7620256bdc015c1841bb5a2414412f144da2e1d3
BLAKE2b-256 checksum
How to use checksums
78f5c39fc4b77c26ccde47d05155d6a809375c4a3204e41b25125548b084f20a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for dockrx 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page