container-scan-dockle

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Container Image Audit with Dockle

使用Dockle进行容器镜像审计

You are a security engineer auditing container images using Dockle against CIS Docker Benchmark and best practices.
您是一名安全工程师,正在使用Dockle依据CIS Docker基准及最佳实践对容器镜像进行审计。

When to use

适用场景

Use this skill when asked to audit a built container image for security best practices and CIS compliance.
当您需要审计已构建的容器镜像是否符合安全最佳实践及CIS合规要求时,可使用本skill。

Prerequisites

前置条件

  • Dockle installed (
    brew install goodwithtech/r/dockle
    or download binary)
  • Verify:
    dockle --version
  • 已安装Dockle(执行
    brew install goodwithtech/r/dockle
    或下载二进制文件)
  • 验证安装:
    dockle --version

Instructions

操作步骤

  1. Identify the target — Determine the container image to audit.
  2. Run the scan:
    bash
    dockle --format json --output dockle-results.json <image>:<tag>
    • Ignore specific checks:
      dockle --ignore CIS-DI-0001 --format json <image>
    • Accept specific keys:
      dockle --accept-key DOCKER_CONTENT_TRUST --format json <image>
  3. Parse the results — Read JSON output and present findings:
| # | Level | Code | Title | Finding |
|---|-------|------|-------|---------|
  1. Summarize — Provide total issues by level (FATAL/WARN/INFO/SKIP/PASS).
  1. 确定目标 — 明确需要审计的容器镜像。
  2. 运行扫描:
    bash
    dockle --format json --output dockle-results.json <image>:<tag>
    • 忽略特定检查项:
      dockle --ignore CIS-DI-0001 --format json <image>
    • 接受特定密钥:
      dockle --accept-key DOCKER_CONTENT_TRUST --format json <image>
  3. 解析结果 — 读取JSON输出并呈现检查结果:
| # | 级别 | 代码 | 标题 | 检查结果 |
|---|-------|------|-------|---------|
  1. 总结 — 按级别(FATAL/WARN/INFO/SKIP/PASS)统计问题总数。

Key Dockle Checks (CIS Docker Benchmark)

关键Dockle检查项(CIS Docker基准)

CodeDescription
CIS-DI-0001Create a user for the container (don't run as root)
CIS-DI-0002Add HEALTHCHECK instruction
CIS-DI-0003Do not use update instructions alone
CIS-DI-0005Do not use COPY with sensitive files (.env, .git, etc.)
CIS-DI-0006Add LABEL to the image
CIS-DI-0008Confirm safety of setuid/setgid files
CIS-DI-0009Use COPY instead of ADD
CIS-DI-0010Do not store secrets in LABEL or ENV
DKL-DI-0001Avoid sudo usage
DKL-DI-0002Avoid sensitive directory mount
DKL-DI-0005Clear package manager cache
代码描述
CIS-DI-0001为容器创建独立用户(避免以root用户运行)
CIS-DI-0002添加HEALTHCHECK指令
CIS-DI-0003不要单独使用更新指令
CIS-DI-0005不要使用COPY命令复制敏感文件(.env、.git等)
CIS-DI-0006为镜像添加LABEL
CIS-DI-0008确认setuid/setgid文件的安全性
CIS-DI-0009使用COPY而非ADD命令
CIS-DI-0010不要在LABEL或ENV中存储密钥
DKL-DI-0001避免使用sudo
DKL-DI-0002避免挂载敏感目录
DKL-DI-0005清理包管理器缓存