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

 

相关内容

热门资讯

这一现象值得深思!wepoke... 这一现象值得深思!wepoker怎么下载游戏,hhpoker俱乐部是干嘛的,原来真的有挂(有挂细节)...
刚刚!智星菠萝透视,拱趴大菠萝... 刚刚!智星菠萝透视,拱趴大菠萝挂,果然是有挂(有挂规律)1)拱趴大菠萝挂辅助插件:进一步探索拱趴大菠...
这一问题亟待解决!wepoke... 这一问题亟待解决!wepoker怎么挂底牌,wpk辅助购买,真是存在有挂(有挂教学)1、wepoke...
备受关注的!哈糖大菠萝辅助器,... 备受关注的!哈糖大菠萝辅助器,德扑圈透视挂,确实是有挂(有挂教程)1、让任何用户在无需哈糖大菠萝辅助...
围绕透视问题!hhpoker可... 围绕透视问题!hhpoker可以控制吗,约局吧开挂,竟然存在有挂(有挂分享)所有人都在同一条线上,像...
插件辅助挂!pokernow辅... 插件辅助挂!pokernow辅助控制,wepoker好友助力码,果然是真的有挂(证实有挂)1)wep...
黑科技辅助挂!uupoker有... 黑科技辅助挂!uupoker有透视吗,wepokerplus外挂,真是是真的有挂(有挂细节)1、点击...
网友热议!德州之星扫描器,we... 网友热议!德州之星扫描器,wepoker俱乐部辅助,都是是真的有挂(揭秘有挂)1.wepoker俱乐...
黑科技辅助挂!红龙poker有... 黑科技辅助挂!红龙poker有辅助吗,wepoker破解工具,好像确实有挂(有挂辅助)1、在红龙po...
2026版攻略!aapoker... 2026版攻略!aapoker发牌逻辑,德普之星私人局辅助器,一贯真的是有挂(真的有挂)1、完成德普...