Skip to main content

autohooks-plugin-hadolint

PyPI release

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autohooks-plugin-hadolint 0.1.0
File Size Uploaded
autohooks_plugin_hadolint-0.1.0.tar.gz 20.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autohooks-plugin-hadolint 0.1.0
File Interpreter ABI Platform
autohooks_plugin_hadolint-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.3 kB

Release files / autohooks_plugin_hadolint-0.1.0.tar.gz

Download URL autohooks_plugin_hadolint-0.1.0.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4f1114964f68e45410ea55a2d94b9060603a03799ef4ab75b095fbfa35ac3013
BLAKE2b-256 checksum
How to use checksums
18d29b229c512449bc2f1f2bd658d967decf49bd4d928d40007031a5652fb3f8
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.0-py3-none-any.whl

Download URL autohooks_plugin_hadolint-0.1.0-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a36121b44c8e522eb40a2201c7296379889cce7f27a057a2a95f51b8cc5a1443
BLAKE2b-256 checksum
How to use checksums
40238077fcdb7785276a05216e3f933ca7a2c410eb121a755ebc595d6c8c87fb
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 history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page