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

 

相关内容

热门资讯

实测揭晓!温州茶苑手机辅助器,... 【亲,温州茶苑手机辅助器 这款游戏可以开挂的,确实是有挂的,很多玩家在这款温州茶苑手机辅助器中打牌都...
科技分享!边锋老友荣成辅助,越... 科技分享!边锋老友荣成辅助,越局吧可以看到别人底牌,最初有开挂辅助神器(讲解有挂);无需打开直接搜索...
玩家必看科普!腾威互娱破解辅助... 玩家必看科普!腾威互娱破解辅助工具,长春科乐作弊,细节开挂辅助下载(有挂实锤);无需打开直接搜索打开...
每日必看推荐!战神辅助众包,卡... 每日必看推荐!战神辅助众包,卡五星辅助工具,一向有开挂辅助挂(竟然有挂);无需打开直接搜索薇:136...
重大推荐!广东雀伸辅助器,福建... 重大推荐!广东雀伸辅助器,福建天天开心辅助,教会辅助开挂神器(发现有挂)您好:福建天天开心辅助这款游...
揭秘!青龙辅助3.0,hhpo... 揭秘!青龙辅助3.0,hhpoker免费辅助器,本来有开挂辅助平台(有挂透视);打开点击测试直接进入...
必看攻略!荔枝竞技破解版,胡乐... 您好:胡乐辅助脚本可靠吗这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用户的...
专业讨论!兴动互娱辅助工具免费... 专业讨论!兴动互娱辅助工具免费,杭州边锋网络游戏辅助,从来有开挂辅助平台(有挂方略)1、下载安装好杭...
科技介绍!微乐小程序免费黑科技... 微乐小程序免费黑科技是一款专注玩家量身打造的游戏记牌类型软件,在微乐小程序免费黑科技这款游戏中我们可...
三分钟了解!微乐江苏小程序游戏... 三分钟了解!微乐江苏小程序游戏破解下载,乐乐围棋入门辅助,原先有开挂辅助神器(讲解有挂)1、下载安装...