CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

nerdctl

$ nerdctl 基金会 中风险
containerd / CNCF · 云原生与基础设施 · Apache-2.0 · macos / linux / windows

nerdctl 是面向 containerd 的 Docker 兼容命令行工具,支持无 root 容器、BuildKit 构建、延迟拉取(Stargz/Nydus)及 Compose 编排。ps、images、inspect 等查询命令均支持 --format json 与 Go 模板。

FCRS-1.0 综合评分
82 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install nerdctl
CLI vs MCP 选型建议 仅 CLI 可用

nerdctl 直接与本地 containerd 套接字及 BuildKit 通信,直接通过 CLI 配合 --format json 即可高效使用。

Agent 友好度体检单

✓ 原生 JSON 输出
✓ 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 21 / 25

ps、images 与 inspect 均支持 --format json 及 Go 模板字段筛选,但缺少全局 --dry-run。

  • nerdctl ps --format json and nerdctl inspect output structured JSON
  • Docker-compatible flags for non-interactive execution
安全与权限边界 19 / 25

支持无 root 运行模式与 --namespace 命名空间隔离,但 rm/prune 等破坏性操作无 --dry-run。

  • Supports rootless mode and containerd --namespace isolation
  • No global --dry-run on compose or system prune
安装与运行摩擦 12 / 15

Linux 下原生对接 containerd;macOS 与 Windows 需借助 Lima 或 Rancher Desktop 等 Linux 虚拟机。

  • Linux-native containerd client; macOS uses Lima VM wrapper
能力覆盖与边际价值 13 / 15

直接复刻 Docker 使用体验管理 containerd,还支持 k8s.io 命名空间排查与 nerdctl compose。

  • Inspects Kubernetes k8s.io containerd containers without Docker daemon
维护与来源背书 9 / 10

CNCF 官方子项目(containerd/nerdctl),Apache-2.0 协议。

  • Maintained under CNCF containerd/nerdctl
文档与可验证性 8 / 10

containerd/nerdctl/docs 提供详尽的功能指南与命令说明。

  • Upstream docs at github.com/containerd/nerdctl/tree/main/docs

安全边界、鉴权与放权指南

鉴权方式
无需鉴权 本地配置文件
凭证存储位置

读取 ~/.docker/config.json 中的 OCI 仓库凭证,并通过 CONTAINERD_ADDRESS 连接 containerd 套接字。

潜在副作用
只读查询 本地写入 远端写入 破坏性删除
费用与配额提示

CNCF 开源项目(Apache-2.0),完全免费。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# nerdctl Agent Rules
- Specify `--namespace <ns>` (e.g., `k8s.io` vs `default`) when inspecting containerd workloads.
- Prefer `--format json` on `ps`/`images`/`inspect` and pass `--rm` for ephemeral `nerdctl run` checks.
- Never run `nerdctl system prune -a --volumes` without explicit approval.

Agent 高频安全命令配方

只读查询(安全推荐)

以 JSON 列出 containerd 容器
nerdctl ps -a --format json

按 JSON 行输出当前 containerd 命名空间内各容器的 ID、镜像、状态与端口。

以 JSON 检查镜像或容器元数据
nerdctl inspect alpine:latest --format '{{json .}}'

输出完整的 containerd/OCI 对象 JSON 配置信息。

受控写入与预演

运行自动清理的隔离测试命令
nerdctl run --rm --platform linux/amd64 alpine:latest uname -m

显式指定 --platform 与 --rm 运行单次命令并在结束后自动删除容器。

核心优势

  • + 在原生 containerd 上提供 Docker 兼容命令与 --format json 输出。
  • + 可通过 --namespace k8s.io 直接排查 Kubernetes 节点容器。
  • + 支持无 root 模式、BuildKit 构建与 nerdctl compose。

注意事项与踩坑点

  • ! 非 Linux 平台(macOS/Windows)需依赖 Lima、Colima 或 Rancher Desktop 等虚拟机。
  • ! compose 与 system prune 缺少全局 --dry-run 预演参数。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI