autohooks-plugin-hadolint
An autohooks plugin for Dockerfile linting via hadolint.
On git commit the plugin runs hadolint against every staged Dockerfile. If
hadolint reports a violation the commit is aborted and the findings are printed.
Installation
Install the plugin
Using uv (recommended):
uv add --dev autohooks-plugin-hadolint
Using pip:
python3 -m pip install --user autohooks-plugin-hadolint
Install hadolint
hadolint is a standalone binary and not a Python package, so it is not installed as a dependency of this plugin. Pick whichever route suits you:
brew install hadolint
sudo apt-get install hadolint
Or download a release binary from
hadolint/hadolint and put it on
your PATH.
You can also skip the local install entirely and run hadolint through Docker — see Running hadolint from a container.
Usage
Activate the plugin:
uv run autohooks plugins add autohooks.plugins.hadolint
or add it to your pyproject.toml directly:
[tool.autohooks]
mode = "uv"
pre-commit = ["autohooks.plugins.hadolint"]
and install the git hook itself:
uv run autohooks activate --mode uv
Configuration
All settings live under [tool.autohooks.plugins.hadolint] in your
pyproject.toml. Every key is optional.
| Key | Default | Description |
|---|---|---|
command |
["hadolint"] |
Full argv prefix used to run hadolint. {root} is replaced with the project root path. |
arguments |
["--no-color", "--format", "tty"] |
Arguments appended to command. Replaces the defaults entirely when set. |
include |
["Dockerfile", "Dockerfile.*", "*.Dockerfile", "*.dockerfile", "Containerfile", "Containerfile.*"] |
Patterns deciding which staged files are Dockerfiles. Matched against both the full path and the file name with fnmatch. |
Each key also accepts a bare string instead of a list.
Running a local binary
[tool.autohooks.plugins.hadolint]
command = ["hadolint"]
arguments = ["--no-color", "--format", "tty", "--failure-threshold", "warning"]
Running hadolint from a container
The plugin passes each Dockerfile as a path relative to the project root, so
mounting the root into the container is all that is needed. Use the {root}
placeholder for the mount source:
[tool.autohooks.plugins.hadolint]
command = [
"docker", "run", "--rm",
"-v", "{root}:/repo", "-w", "/repo",
"hadolint/hadolint", "hadolint",
]
The same works for podman or a wrapper script — the first element of
command is what the plugin checks for on your PATH.
hadolint's own configuration
Rules are configured by hadolint itself, for example through a .hadolint.yaml
in the repository root:
ignored:
- DL3008
When running from a container, make sure the config file is inside the mounted
directory (it is, with the {root} mount above).
Example
Copy examples/binary or examples/docker into a git repository of its own and follow examples/README.md to watch a commit get rejected and then pass.
Contributing
Contributions are welcome. Please open a pull request on GitHub — for larger changes, please open an issue first so the approach can be discussed.
Development setup
The project uses uv:
uv sync
Run the tests:
uv run pytest
One test exercises the real hadolint binary and is skipped when hadolint is not
on your PATH, so install it to run the full suite.
Lint and format with ruff:
uv run ruff check . && uv run ruff format .
The repository uses its own hooks — ruff and this plugin run on every commit. Install them once with:
uv run autohooks activate --mode uv
License
Copyright (C) 2026 Muthu Kumaran R
Licensed under the GNU General Public License v3.0 or later.
Metadata
Release files for autohooks-plugin-hadolint 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| autohooks_plugin_hadolint-0.1.1.tar.gz | 20.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| autohooks_plugin_hadolint-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.1 kB
Release files / autohooks_plugin_hadolint-0.1.1.tar.gz
| Download URL | autohooks_plugin_hadolint-0.1.1.tar.gz |
|---|---|
| Size | 20.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
405e832e77d73942a19139b9230e94a5d0054f41777abb0ae1841c704d61c9ed
|
|
BLAKE2b-256 checksum How to use checksums |
b674ea8fa2da856f251936551c94fab92b995508b9079a89da022cfa8e2e8f58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / autohooks_plugin_hadolint-0.1.1-py3-none-any.whl
| Download URL | autohooks_plugin_hadolint-0.1.1-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f585f385ad27ada9a5b252b15d8081b79a999d4320057c71ddd6431403b80c3
|
|
BLAKE2b-256 checksum How to use checksums |
5d35549bd64de42cdaf1841616476ae4082a3f078059ce8ecb1fd53d8a00ea64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|