Generate pre-commit hooks for Dockerfile linting with hadolint
Generates pre-commit hooks for Dockerfile linting using hadolint to enforce best practices.
npx claudepluginhub jugrajsingh/skillgardenThis skill is limited to using the following tools:
Add Dockerfile linting to pre-commit configuration.
Hadolint is the standard Dockerfile linter. It:
Glob: **/Dockerfile, **/Dockerfile.*, **/*.dockerfile
If no Dockerfiles found, report and exit.
Glob: .pre-commit-config.yaml
If exists, merge hadolint hook. If not, create minimal config.
# Dockerfile linting
- repo: https://github.com/hadolint/hadolint
rev: v2.12.0
hooks:
- id: hadolint-docker
args: ["--ignore", "DL3008", "--ignore", "DL3013"]
| Code | Rule | When to Ignore |
|---|---|---|
| DL3008 | Pin apt versions | Dev images where latest is OK |
| DL3013 | Pin pip versions | When using requirements.txt |
| DL3018 | Pin apk versions | Alpine dev images |
| DL3059 | Multiple consecutive RUN | Readability preference |
Create project-level config for consistent ignores:
# .hadolint.yaml
ignored:
- DL3008 # apt-get version pinning
- DL3013 # pip version pinning
trustedRegistries:
- docker.io
- gcr.io
- ghcr.io
Added Docker linting to pre-commit:
Hook: hadolint-docker
Files: Dockerfile, Dockerfile.*, *.dockerfile
Common commands:
hadolint Dockerfile # Lint single file
hadolint --ignore DL3008 ... # Ignore specific rule
Docs: https://github.com/hadolint/hadolint
Security (critical):
Efficiency:
Maintainability: