hadolint

Dockerfile 静态检查工具

补充说明

hadolint 检查 Dockerfile 的最佳实践和常见错误,内置 ShellCheck 检查 RUN 中的 shell 片段。它只分析 Dockerfile,不分析构建出的镜像。

常用示例

hadolint Dockerfile
hadolint --format json Dockerfile
hadolint --failure-threshold warning Dockerfile
hadolint --ignore DL3008 Dockerfile
hadolint --config .hadolint.yaml Dockerfile

.hadolint.yaml:

failure-threshold: warning
ignored:
  - DL3008
  - DL3013
trustedRegistries:
  - docker.io
  - registry.example.com

易错点与排错

相关命令