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

 

相关内容

热门资讯

黑科技苹果版(wepoke透明... 黑科技苹果版(wepoke透明黑科技)wepower有外挂(we-poker)确实有挂(有挂攻略)-...
黑科技讲解(wpk ai辅助)... 黑科技讲解(wpk ai辅助)wpk微扑克有辅助吗(wPK)一直有挂(果真有挂)-哔哩哔哩;运wpk...
黑科技教学!微扑克辅助机器人(... 黑科技教学!微扑克辅助机器人(wepokeai代打)本来真的是有挂(有挂透明挂黑科技)-哔哩哔哩1、...
黑科技辅助(wpk德州测试外挂... 黑科技辅助(wpk德州测试外挂)都是真的是有挂(软件透明挂)详细教程(有挂功能)-哔哩哔哩是一款可以...
黑科技新版(wpk最新黑科技)... 黑科技新版(wpk最新黑科技)wpk辅助器小程序(Wpk)其实真的是有挂(发现有挂)-哔哩哔哩1、实...
黑科技智能ai!德扑之星软件透... 黑科技智能ai!德扑之星软件透明软件多少钱(德州ai人工智能)果然是真的有挂(有挂黑科技ai)-哔哩...
黑科技最新(wepokeai代... 黑科技最新(wepokeai代打)wepoke有插件吗(wepOke)原来有挂(有挂猫腻)-哔哩哔哩...
黑科技辅助(aapoker钻石... 黑科技辅助(aapoker钻石代理有挂的)原先是有挂(软件透明挂)科技教程(真的有挂)-哔哩哔哩;致...
黑科技游戏(wpk ai辅助)... 黑科技游戏(wpk ai辅助)wpk ai辅助有没有用(wpK)一直是真的有挂(有挂教程)-哔哩哔哩...
辅助黑科技!微扑克数据采集(w... 辅助黑科技!微扑克数据采集(wepoke透明黑科技)切实存在有挂(有挂软件透明挂)-哔哩哔哩;1、游...