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

 

相关内容

热门资讯

今天上午!poker mast... 今天上午!poker master辅助,德普之星私人局辅助免费(透视)指南教程(切实是有挂)今天上午...
透视专业!德州透视插件(透视)... 透视专业!德州透视插件(透视)wpk德州局透视,教程办法(有挂规律)-哔哩哔哩1、德州透视插件免费脚...
更值得关注的是!wepoker... 更值得关注的是!wepoker智能辅助插件,hhpoker是内部控制吗(透视)讲义教程(本来是有挂)...
透视详细!aapoker俱乐部... 透视详细!aapoker俱乐部靠谱吗(透视)佛手在线大菠萝为什么都输,教程讲义(有挂讲解)-哔哩哔哩...
截至发稿!wepoker辅助软... 截至发稿!wepoker辅助软件价格,wepoker代打辅助机器人(透视)步骤教程(竟然有挂)1、下...
透视透视!aapoker透视脚... 透视透视!aapoker透视脚本(透视)pokerworld软件,教程学习(有挂攻略)-哔哩哔哩1、...
在玩家背景下!pokemmo辅... 在玩家背景下!pokemmo辅助官网,hhpoker破解工具(透视)模块教程(本来真的是有挂)1、进...
透视必备!wepoker俱乐部... 透视必备!wepoker俱乐部辅助(透视)微扑克微乐辅助,教程窍门(有挂方略)-哔哩哔哩1、不需要A...
截至目前!菠萝德州透视脚本,如... 截至目前!菠萝德州透视脚本,如何下载德普之星辅助软件(透视)指南书教程(真是存在有挂)1、很好的工具...
透视开挂!hhpoker是真的... 透视开挂!hhpoker是真的假的(透视)pokemmo修改器手机版,教程演示(有人有挂)-哔哩哔哩...