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

PyPI publish is coming soon for 0.1.0. Until then, install from source as above.

# after publish:
# pip install dockrx
# pipx install dockrx

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

  • PyPI publish
  • 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.0.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.0-py3-none-any.whl (74.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dockrx-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 a8286c4576121ad5c1fbdb137792f443ceb53380ae8ac55eaaa4e41e1d1751b7
MD5 6e82acc97fbd10c605cf9b4e6d07b089
BLAKE2b-256 8f8148baab97ab79395374668ff3ccd1377be9768c0f544e58e3c0c3e837bc8b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dockrx-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a19d81ce5edf1bcf3f90996e3c8fd4f6d2ef8aeb8d04e2547abfe14fac3dba3
MD5 1f5fc2b9a396f2d9c979ac715057701f
BLAKE2b-256 cd7594eeff67c3660443d142a5d7b8dd8a238cc1713421ce10f689362a19b5b0

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