Skip to main content

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

Project description

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

From source (recommended for alpha)

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dockrx-0.1.1.tar.gz (50.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dockrx-0.1.1-py3-none-any.whl (74.7 kB view details)

Uploaded Python 3

File details

Details for the file dockrx-0.1.1.tar.gz.

File metadata

  • Download URL: dockrx-0.1.1.tar.gz
  • Upload date:
  • Size: 50.1 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for dockrx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 160ebfa4ed7e2dfdf3afe9d73e312e5501798b4add8a7827d8657f7704bdb04a
MD5 391490685860ffcfded89b1e49e0deb9
BLAKE2b-256 d9a77615ead60c1ebccbd9e3af5eab20151c6a688984db8f041363addf0762ae

See more details on using hashes here.

File details

Details for the file dockrx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dockrx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 74.7 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for dockrx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 69e2c26ac558b90803690dcf7620256bdc015c1841bb5a2414412f144da2e1d3
MD5 deeae276f297b1cec403389ec6ddd79f
BLAKE2b-256 78f5c39fc4b77c26ccde47d05155d6a809375c4a3204e41b25125548b084f20a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page