Analyze Dockerfiles. Explain size, caching, and security problems with actionable fixes.
Project description
DockRx
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.
Alpha note: image-size and build-time numbers in the report are heuristic estimates, not measured from real builds.
dockrx fix/suggestauto-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(writesDockerfile.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 aredockrx. Clone intodocrx, run the tool asdockrx.
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 explainrule documentationdockrx fix/suggest— non-destructive rewrite toDockerfile.fixed(subset of rules)dockrx comparebefore/after Dockerfile comparisondockrx badgehealth-grade SVG/markdown badgesdockrx formatDockerfile formatter (--check/--diffsafe;--writeoverwrites in place)- JSON output for CI or automation
- Project-local rule and plugin overrides
- Configurable via
[tool.dockrx]inpyproject.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 inENV, debug tools in runtime) - image-size reductions (JDK in runtime, large base images, build tools in final stage)
- best practices (
HEALTHCHECK,LABEL,.dockerignore,ADDvsCOPY)
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
- Commands:
docs/commands.md - Web playground & API: dockrx.vercel.app ·
docs/web-api.md - Extending DockRx:
docs/extending.md - Architecture and scope:
docs/architecture.md - Roadmap:
docs/roadmap.md - Changelog:
CHANGELOG.md - Contributing:
CONTRIBUTING.md
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
160ebfa4ed7e2dfdf3afe9d73e312e5501798b4add8a7827d8657f7704bdb04a
|
|
| MD5 |
391490685860ffcfded89b1e49e0deb9
|
|
| BLAKE2b-256 |
d9a77615ead60c1ebccbd9e3af5eab20151c6a688984db8f041363addf0762ae
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69e2c26ac558b90803690dcf7620256bdc015c1841bb5a2414412f144da2e1d3
|
|
| MD5 |
deeae276f297b1cec403389ec6ddd79f
|
|
| BLAKE2b-256 |
78f5c39fc4b77c26ccde47d05155d6a809375c4a3204e41b25125548b084f20a
|