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

 

相关内容

热门资讯

一秒答解辅助!十三张麻将辅助多... 一秒答解辅助!十三张麻将辅助多功能AI脚本,十三张麻将一直是有辅助脚本1、十三张麻将免费辅助多个强度...
一分钟了解外挂!来局麻将外挂多... 一分钟了解外挂!来局麻将外挂多功能AIapp,来局麻将确实真的有外挂app来局麻将透视方法中分为三种...
每日必备开挂!哈狗麻将开挂多功... 每日必备开挂!哈狗麻将开挂多功能AI插件,哈狗麻将确实是真的有开挂插件1、点击下载安装,哈狗麻将脚本...
我来教大家辅助!哈哈贵阳捉鸡麻... 我来教大家辅助!哈哈贵阳捉鸡麻将辅助多功能AI攻略,哈哈贵阳捉鸡麻将好像是真的有辅助攻略1、进入游戏...
今日科普辅助!约游麻将辅助多功... 今日科普辅助!约游麻将辅助多功能AI插件,约游麻将竟然真的是有辅助插件1、打开软件启动之后找到中间准...
推荐十款外挂!微友南昌麻将外挂... 推荐十款外挂!微友南昌麻将外挂多功能AI脚本,微友南昌麻将确实有外挂脚本在进入微友南昌麻将软件靠谱后...
免费测试版透视挂!杭州都莱麻将... 免费测试版透视挂!杭州都莱麻将透视挂多功能AI技巧,杭州都莱麻将本来是有透视挂技巧1、操作简单,无需...
发现一款辅助器!十三张麻将辅助... 发现一款辅助器!十三张麻将辅助器多功能AI脚本,十三张麻将一直是真的有辅助器脚本1)十三张麻将辅助插...
带你了解辅助器!红中麻将辅助器... 带你了解辅助器!红中麻将辅助器多功能AI软件,红中麻将原来有辅助器软件1、让任何用户在无需红中麻将安...
重大科普透视挂!闲来跑胡子透视... 重大科普透视挂!闲来跑胡子透视挂多功能AI攻略,闲来跑胡子真是存在有透视挂攻略重大科普透视挂!闲来跑...