A pre-commit hook for hadolint that automatically downloads and installs the hadolint binary — no manual installation required.
The official hadolint/hadolint repository provides a pre-commit hook configuration, but it does not auto-install the hadolint binary. Users who add it to their .pre-commit-config.yaml are met with:
Executable `hadolint` not found
This is a known, long-standing issue that affects everyone who tries to use hadolint as a zero-dependency pre-commit hook. The official hook assumes you have already installed hadolint separately (e.g. via brew install hadolint), which defeats the purpose of a self-contained pre-commit integration.
This project solves that problem. It distributes the official, pre-built hadolint binary through PyPI as a platform-specific wheel. When pre-commit sets up the hook environment, it runs pip install hadolint-py automatically — and your binary is ready to use.
Add the following to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/shenxianpeng/hadolint-pre-commit
rev: v2.14.0.1
hooks:
- id: hadolintRun pre-commit install and the hadolint binary will be downloaded and installed automatically. That's it.
You can pass any hadolint CLI argument via the args key:
repos:
- repo: https://github.com/shenxianpeng/hadolint-pre-commit
rev: v2.14.0.1
hooks:
- id: hadolint
args: [--ignore, DL3008, --ignore, DL3009]hadolint supports a .hadolint.yaml file in your project root. Create it alongside your Dockerfiles:
# .hadolint.yaml
ignore:
- DL3008 # Pin versions in apt-get install
- DL3009 # Delete the apt-get lists after installing
failure-threshold: warning
trustedRegistries:
- docker.io
- gcr.ioWhen a .hadolint.yaml is present, hadolint picks it up automatically — no extra args needed.
This package ships the hadolint binary via PyPI using
setuptools-download.
When pip install hadolint-py is run (which pre-commit does automatically),
the appropriate pre-built binary for your platform is downloaded from the
official hadolint GitHub releases
and placed in your environment's bin/ directory (or Scripts/ on Windows).
| OS | Architecture |
|---|---|
| Linux | x86_64 |
| Linux | arm64 |
| macOS | x86_64 |
| macOS | arm64 |
| Windows | x86_64 |
| Approach | Auto-installs binary | Works offline after install | Cross-platform | Zero extra setup |
|---|---|---|---|---|
| This project | ✅ | ✅ | ✅ | ✅ |
hadolint/hadolint official hook |
❌ (requires pre-installed hadolint) |
✅ | ✅ | ❌ |
brew install hadolint + system hook |
❌ (manual step) | ✅ | ❌ | |
| Docker-based hook | ✅ | ✅ | ✅ | ❌ (requires Docker) |
You can also use hadolint-py outside of pre-commit as a standalone CLI tool:
pip install hadolint-py
hadolint --version
hadolint DockerfileContributions are welcome! Please open an issue or pull request on GitHub.