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、金币登录送、破产送、升级送、活动送。...
现有说明如下!海贝之城有辅助吗... 现有说明如下!海贝之城有辅助吗(辅助)原来是有辅助器(有挂解惑)1、进入游戏-大厅左侧-新手福利-激...
这一问题亟待解决!传送屋辅助(... 这一问题亟待解决!传送屋辅助(辅助)一贯是有辅助插件(有挂教程)1、实时传送屋辅助透视辅助更新:用户...
最终!阿拉斗牌辅助(辅助)竟然... 最终!阿拉斗牌辅助(辅助)竟然是真的有辅助app(真的有挂)1、阿拉斗牌辅助有没有辅助教程、阿拉斗牌...
据权威媒体报道!皮皮辅助器(辅... 据权威媒体报道!皮皮辅助器(辅助)真是是有辅助app(真实有挂)1、完成皮皮辅助器有辅助插件,帮助玩...
近日!圣盛荆州晃晃辅助工具(辅... 近日!圣盛荆州晃晃辅助工具(辅助)竟然真的是有辅助攻略(确实有挂)1、操作简单,无需圣盛荆州晃晃辅助...
日前!德友汇辅助器(辅助)切实... 日前!德友汇辅助器(辅助)切实真的有辅助攻略(有挂细节)1、玩家可以在德友汇辅助器透视最简单三个步骤...
黑科技攻略!四川熊猫辅助(辅助... 黑科技攻略!四川熊猫辅助(辅助)一贯是真的有辅助挂(有挂细节)1、用户打开应用后不用登录就可以直接使...
经调查!微信呢微乐游戏辅助脚本... 经调查!微信呢微乐游戏辅助脚本(辅助)其实真的有辅助方法(有挂教程)微信呢微乐游戏辅助脚本能透视中分...