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

 

相关内容

热门资讯

目前来看!四川游戏家园破解,真... 目前来看!四川游戏家园破解,真是存在有辅助修改器(有挂方针)-哔哩哔哩1、进入到四川游戏家园破解是否...
据监测!宁波同乐游辅助下载,其... 据监测!宁波同乐游辅助下载,其实是有辅助挂(有挂技巧)-哔哩哔哩1、据监测!宁波同乐游辅助下载,其实...
反观!新九哥智能辅助app,都... 反观!新九哥智能辅助app,都是是真的辅助工具(今日头条)-哔哩哔哩1、上手简单,内置详细流程视频教...
今天下午!湖北逍遥辅助,本来是... 今天下午!湖北逍遥辅助,本来是真的辅助软件(有挂工具)-哔哩哔哩所有人都在同一条线上,像星星一样排成...
随着!新九哥智能辅助app,其... 随着!新九哥智能辅助app,其实有挂辅助挂(确实有挂)-哔哩哔哩1、全新机制【新九哥智能辅助appa...
连日来!聚友联盟免费辅助器,其... 连日来!聚友联盟免费辅助器,其实真的是有辅助器(真的有挂)-哔哩哔哩1、聚友联盟免费辅助器免费辅助多...
据悉!上品游戏破解,真是是有辅... 据悉!上品游戏破解,真是是有辅助app(有挂猫腻)-哔哩哔哩1)上品游戏破解有没有挂:进一步探索上品...
据统计!新悠悠辅助微信,都是是... 据统计!新悠悠辅助微信,都是是真的辅助安装(有挂功能)-哔哩哔哩该软件可以轻松地帮助玩家将新悠悠辅助...
此事迅速冲上热搜!乐酷副厅辅助... 此事迅速冲上热搜!乐酷副厅辅助,真是真的有辅助神器(确实有挂)-哔哩哔哩1、打开软件启动之后找到中间...
今天下午!微信小程序透视微乐辅... 今天下午!微信小程序透视微乐辅助器免费安装,一直存在有辅助工具(有挂总结)-哔哩哔哩1、每一步都需要...