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

 

相关内容

热门资讯

2分钟辅助挂!掌心麻将圈会搞鬼... 2分钟辅助挂!掌心麻将圈会搞鬼吗,雀神微信开挂小程序,详细教程(有挂胜率);小薇(透视辅助)致您一封...
四分钟辅助挂!微乐小程序免费黑... 四分钟辅助挂!微乐小程序免费黑科技,七彩全民雀神苹果手机,详细教程(有挂工具)是一款可以让一直输的玩...
四分钟辅助挂!多乐第三方辅助器... 四分钟辅助挂!多乐第三方辅助器,广东雀神麻将怎么让系统发好牌,详细教程(有挂攻略)1、广东雀神麻将怎...
7分钟辅助挂!一起三轮车有没有... 您好,微信雀神广东麻雀小程序辅助这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】...
二分钟辅助挂!胡乐麻将挂神器,... 二分钟辅助挂!胡乐麻将挂神器,雀神2024小程序辅助器,详细教程(有挂工具);一、雀神2024小程序...
玩家必备攻略!陕西麻将助赢神器... 玩家必备攻略!陕西麻将助赢神器(透视)外挂透明挂辅助机制(2023已更新)(哔哩哔哩)1、下载好陕西...
揭秘几款!中至常熟麻将技巧(透... 揭秘几款!中至常熟麻将技巧(透视)外挂透视辅助器(2020已更新)(哔哩哔哩);1)中至常熟麻将技巧...
两分钟普及!四川凉山跑得快辅助... 两分钟普及!四川凉山跑得快辅助器,wEpoke一直是有挂,实用技巧(有挂透视)1、下载好四川凉山跑得...
6分钟辅助挂!心悦海南麻将有挂... 自定义雀神小程序辅助输赢系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不...
总算了解!中至乐平麻将攻略(辅... 总算了解!中至乐平麻将攻略(辅助挂)外挂透明挂辅助机制(2024已更新)(哔哩哔哩);该软件可以轻松...