Hadolint提升Dockerfile的质量和安全性 —— 筑梦之路
创始人
2025-01-10 12:38:16
0

https://github.com/hadolint/hadolint

hadolint 在线版本:https://hadolint.github.io/hadolint/

FROM debian RUN export node_version="0.10" \ && apt-get update && apt-get -y install nodejs="$node_verion" COPY package.json usr/src/app RUN cd /usr/src/app \ && npm install node-static  EXPOSE 80000 CMD ["npm", "start"]
nerdctl run --rm -i hadolint/hadolint < Dockerfile  -:1 DL3006 warning: Always tag the version of an image explicitly -:2 DL3015 info: Avoid additional packages by specifying `--no-install-recommends` -:2 DL3009 info: Delete the apt-get lists after installing something -:2 SC2154 warning: node_verion is referenced but not assigned (did you mean 'node_version'?). -:4 DL3045 warning: `COPY` to a relative destination without `WORKDIR` set. -:5 DL3003 warning: Use WORKDIR to switch to a directory -:5 DL3016 warning: Pin versions in npm. Instead of `npm install ` use `npm install @` -:8 DL3011 error: Valid UNIX ports range from 0 to 65535

指定忽略的规则

如何你想忽略某些规则,在项目目录下创建hadolint.yaml文件,并指定要忽略的规则

ignored:   - DL3011

运行Hadolint时指定配置文件

nerdctl run --rm -i -v /root/hadolint-demo/hadolint.yaml:/.config/hadolint.yaml hadolint/hadolint < Dockerfile
-:1 DL3006 warning: Always tag the version of an image explicitly -:2 SC2154 warning: node_verion is referenced but not assigned (did you mean 'node_version'?). -:2 DL3009 info: Delete the apt-get lists after installing something -:2 DL3015 info: Avoid additional packages by specifying `--no-install-recommends` -:4 DL3045 warning: `COPY` to a relative destination without `WORKDIR` set. -:5 DL3003 warning: Use WORKDIR to switch to a directory -:5 DL3016 warning: Pin versions in npm. Instead of `npm install ` use `npm install @`

为了确保Dockerfiles的质量和安全性,将Hadolint集成到开发工作流程中是一个明智之举。这样可以在代码编写、提交前以及持续集成(CI)过程中自动检测潜在问题。以下是一些常见的集成方式:

  • 代码审查平台集成

https://github.com/hadolint/hadolint/blob/master/docs/INTEGRATION.md#code-review

  • 持续集成

https://github.com/hadolint/hadolint/blob/master/docs/INTEGRATION.md#continuous-integration

  • 编辑器集成

https://github.com/hadolint/hadolint/blob/master/docs/INTEGRATION.md#editors

  • 版本控制集成

https://github.com/hadolint/hadolint/blob/master/docs/INTEGRATION.md#version-control

 

相关内容

热门资讯

透视新版!aapoker怎么设... 透视新版!aapoker怎么设置抽水,aapoker真的假的,规律教程(有挂规律);1、aapoke...
透视工具!aapoker辅助怎... 透视工具!aapoker辅助怎么用,aapoker怎么设置提高好牌几率,揭秘攻略(有挂细节);在进入...
透视有挂!aapoker透视脚... 透视有挂!aapoker透视脚本,aapoker辅助器怎么用,技巧教程(有挂黑科技);1、金币登录送...
透视能赢!aapoker公共底... 透视能赢!aapoker公共底牌,aapoker安装包怎么使用,必赢方法(有挂教程)1、让任何用户在...
透视好牌!aapoker俱乐部... 透视好牌!aapoker俱乐部靠谱吗,aapoker插件,AA德州教程(有挂辅助)aapoker俱乐...
透视计算!aapoker插件下... 透视计算!aapoker插件下载,aapoker破解侠是真的吗,揭秘攻略(有挂方法)1、不需要AI权...
透视新版!aapoker ai... 透视新版!aapoker ai插件,aapoker辅助软件合法吗,攻略教程(有挂攻略)进入游戏-大厅...
透视挂!aapoker怎么拿好... 透视挂!aapoker怎么拿好牌,aapoker真的假的,可靠教程(有挂揭秘)1、超多福利:超高返利...
透视挂!aapoker插件,a... 透视挂!aapoker插件,aapoker插件下载,必胜教程(有挂黑科技)1、点击下载安装,aapo...
透视教程!aapoker插件,... 透视教程!aapoker插件,aapoker辅助器是真的吗,高科技教程(有挂解说)1、aapoker...