
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
本镜像是由Tapendium开发团队维护的AWS CloudFormation模板Linter工具容器化版本,基于开源AWS CloudFormation Linter(cfn-lint)构建。该镜像提供轻量级运行环境,可快速集成到开发流程中,对AWS CloudFormation模板进行自动化检查,确保模板质量与合规性。
开发人员在编写CloudFormation模板后,通过本地Docker命令快速运行Linter,即时发现语法错误和最佳实践问题,减少提交到版本控制系统的低质量模板。
作为CI/CD流水线的前置检查步骤,在模板提交或部署前自动运行Linter,阻止不合规模板进入后续流程,降低部署风险。
用于定期批量检查现有CloudFormation模板库,识别历史模板中的潜在问题,确保整体架构符合安全与成本优化最佳实践。
从Docker仓库拉取最新版本镜像:
bashdocker pull tapendium/cfn-linter:latest
如需特定版本,可指定标签(如v0.75.0):
bashdocker pull tapendium/cfn-linter:v0.75.0
检查本地模板文件
将本地CloudFormation模板目录挂载到容器的/templates目录,并指定待检查文件路径:
bashdocker run --rm -v $(pwd):/templates tapendium/cfn-linter cfn-lint /templates/your-template.yaml
--rm:容器退出后自动删除-v $(pwd):/templates:挂载当前目录到容器内/templatescfn-lint /templates/your-template.yaml:运行Linter检查指定模板检查目录下所有模板
批量检查目录中所有.yaml/.yml/.json格式的模板:
bashdocker run --rm -v $(pwd):/templates tapendium/cfn-linter cfn-lint /templates
自定义规则文件
通过挂载自定义规则目录(包含.yml格式规则文件),扩展检查逻辑:
bashdocker run --rm \ -v $(pwd):/templates \ -v $(pwd)/custom-rules:/custom-rules \ tapendium/cfn-linter \ cfn-lint /templates/your-template.yaml -r /custom-rules
-r /custom-rules:指定自定义规则目录路径输出格式设置
指定输出格式为JSON(便于机器解析):
bashdocker run --rm -v $(pwd):/templates tapendium/cfn-linter cfn-lint /templates/your-template.yaml -f json
输出为JUNIT格式(适合CI/CD报告):
bashdocker run --rm -v $(pwd):/templates tapendium/cfn-linter cfn-lint /templates/your-template.yaml -f junit > report.xml
忽略特定规则
通过--ignore参数跳过不需要的检查规则(规则ID可从Linter输出中获取):
bashdocker run --rm -v $(pwd):/templates tapendium/cfn-linter cfn-lint /templates/your-template.yaml --ignore W1001,E2002
在docker-compose.yml中集成Linter,便于与其他工具联动:
yamlversion: '3' services: cfn-linter: image: tapendium/cfn-linter:latest volumes: - ./templates:/templates # 挂载模板目录 - ./custom-rules:/custom-rules # 挂载自定义规则(可选) command: cfn-lint /templates -r /custom-rules -f junit > /templates/report.xml # 输出报告到本地目录
运行检查:
bashdocker-compose run --rm cfn-linter
| 参数 | 描述 | 示例 |
|---|---|---|
-f, --format | 指定输出格式 | -f json |
-r, --rules | 指定自定义规则目录 | -r /custom-rules |
--ignore | 忽略指定规则ID | --ignore W1001,E2002 |
--no-progress | 禁用进度条输出 | --no-progress |
--update-specs | 更新AWS资源规范缓存 | --update-specs |
--update-specs参数更新资源规范缓存,确保检查规则与最新AWS资源类型同步。v0.75.0)以确保检查行为一致性。您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务