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

 

相关内容

热门资讯

重磅来袭!wepoker辅助挂... 重磅来袭!wepoker辅助挂多功能透视工具,真是有挂(有挂猫腻)1、不需要AI权限,帮助你快速的进...
分享一款!aapoker辅助挂... 分享一款!aapoker辅助挂多功能透视工具,竟然存在有挂(有挂详情)1、进入到aapoker是否有...
一分钟了解!德普之星辅助挂多功... 一分钟了解!德普之星辅助挂多功能透视工具,其实存在有挂(有挂详情)1、每一步都需要思考,不同水平的挑...
2024教程!wepoker辅... 2024教程!wepoker辅助挂多功能透视工具,切实是有挂(揭秘有挂)1)wepoker有没有挂:...
重大科普!WPK辅助挂多功能透... 重大科普!WPK辅助挂多功能透视工具,确实真的有挂(确实有挂)1、玩家可以在WPK透视最简单三个步骤...
让我来分享经验!WPK辅助挂多... 让我来分享经验!WPK辅助挂多功能透视工具,确实存在有挂(有挂细节)在进入WPK软件靠谱后,参与本局...
科技分享!wpk辅助挂多功能透... 科技分享!wpk辅助挂多功能透视工具,确实是有挂(有挂工具)1、首先打开wpk辅助器下载最新版本,在...
科技介绍!AAPoKer辅助挂... 科技介绍!AAPoKer辅助挂多功能透视工具,真是有挂(揭秘有挂)1、不需要AI权限,帮助你快速的进...
发现一款!智星德州扑克辅助挂多... 发现一款!智星德州扑克辅助挂多功能透视工具,确实存在有挂(有挂猫腻)1、智星德州扑克免费辅助多个强度...
玩家攻略推荐!红龙poker辅... 玩家攻略推荐!红龙poker辅助挂多功能透视工具,切实是真的有挂(了解有挂)1、红龙poker有没有...