The Complete Production SOP: How to Deploy and Run containerd & nerdctl Docker-Compatible Management in Autonomous AI Agents
Step-by-step SOP to install and run containerd-nerdctl-cli in Codex, Claude Code, and Cursor. Master containerd namespaces, eStargz lazy pulls, and debugging.
Technical Overview & Architectural Context
Autonomous coding agents frequently default to legacy Docker daemon patterns when asked to manage containerized workloads, attempting to interact with `/var/run/docker.sock` or falling back to generic `docker` subcommands that fail on modern containerd-first nodes. Without explicit procedural guardrails, agents hallucinate non-existent flags, ignore containerd namespaces (such as `k8s.io` versus `default`), and miss out on native containerd features like eStargz lazy pulling and BuildKit daemon integration. The `containerd-nerdctl-cli` skill enforces deterministic DevOps procedures across containerd runtimes. It constrains the AI agent to verified `nerdctl` CLI syntax, forces explicit containerd namespace specification, and injects safe execution patterns for rapid image pulling, container lifecycle management, and content store pruning without risking host daemon corruption or breaking Kubernetes node integrity.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Create the local skill manifest directory and inject verified procedural rules into your agent runtime.
To enable your coding agent (Codex, Claude Code, Cursor, or Windsurf) to natively invoke nerdctl operations, mount the skill specification directly into the project's root agent configuration directory (`.agents/skills/containerd-nerdctl-cli`) or global runtime directory (`~/.claude/skills/` or `.cursor/rules/`). The agent runtime parses the YAML frontmatter triggers and registers specific containerd management workflows into its tool evaluation loop.
mkdir -p .agents/skills/containerd-nerdctl-cli && curl -fsSL https://askills.dev/api/skills/containerd-nerdctl-cli/raw -o .agents/skills/containerd-nerdctl-cli/SKILL.md---
name: "containerd-nerdctl-cli"
description: "Manage containerd runtimes directly with full Docker CLI compatibility and containerd features."
metadata:
author: "containerd"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "use nerdctl run"
- "switch containerd namespace"
- "enable estargz lazy pulling nerdctl"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: true
net_access: true
---Keep the SKILL.md body focused on operational constraints. Agents only need the specific flag patterns (e.g., `--namespace`, `--snapshotter=stargz`) rather than full manpages, saving up to 1,500 context tokens per prompt roundtrip.
Ensure that the agent sandbox possesses permission to read `/run/containerd/containerd.sock`. In restricted Cursor or Codex sandboxes, non-root users will encounter permission denied errors unless the socket permissions are updated or rootless mode is enabled.
Containerd Socket & CNI Dependency Validation
Verify socket connectivity, containerd namespace accessibility, and CNI bridge plugin paths.
Before issuing container execution commands, the agent must confirm the status of the containerd daemon and CNI network plugins. Running `nerdctl info` validates that BuildKit is detected, rootless or rootful containerd is operational, and default bridge networks exist. Storing local configurations in `.env.local` preserves agent parameters across sub-sessions.
nerdctl info --format '{{.Server.Version}} (Driver: {{.Snapshotter}})' && echo "NERDCTL_TOML=~/.config/nerdctl/nerdctl.toml" >> .env.localnamespace = "default"
snapshotter = "overlayfs"
cni_path = "/opt/cni/bin"
cni_netconfpath = "/etc/cni/net.d"
insecure_registry = falseDefine default namespace in nerdctl.toml so the AI agent does not inadvertently omit the `--namespace` argument and pollute the host default workspace during Kubernetes debugging.
Adding secrets or registry auth tokens to `.env.local` is safe only if the file is tracked in `.gitignore`. Never hardcode `nerdctl login` credentials in skill execution scripts.
Intent Matching & Trigger Invocation
Trigger deterministic nerdctl workflows using frontmatter-matched prompt phrases.
Agent engines like Claude Code and Codex evaluate system-level prompt triggers against their skill registries. Formulating requests using target triggers such as 'switch containerd namespace' or 'enable estargz lazy pulling nerdctl' causes the runtime to lock into the exact commands and safety guidelines defined in the SOP.
claude "use nerdctl run with estargz lazy pulling for ghcr.io/stargz-containers/python:3.9-esgz on port 8000"#!/usr/bin/env bash
set -euo pipefail
# Verified agent execution pattern with lazy pulling
nerdctl run -d \
--name test-python-service \
--snapshotter=stargz \
-p 8000:8000 \
ghcr.io/stargz-containers/python:3.9-esgz \
python -m http.server 8000Explicitly prompt with exact verbs matching your frontmatter (`switch containerd namespace`, `use nerdctl run`) to ensure zero-shot deterministic routing without ambiguity.
When running lazy-pulled containers via eStargz, ensure the `stargz-snapshotter` daemon is running locally; otherwise nerdctl falls back to standard overlayfs and pulls the full layer.
Verification, Linting & Output Quality Gate
Execute automated status checks and health verification before accepting agent output.
A deterministic agent must verify that the target container reached the running state, ports are mapped correctly, and container logs show no immediate crashes. The verification gate requires inspecting the container via `nerdctl inspect` and checking the return code.
nerdctl ps --filter name=test-python-service && nerdctl inspect --format '{{.State.Status}}' test-python-service | grep -q 'running'#!/usr/bin/env bash
status=$(nerdctl inspect --format '{{.State.Status}}' test-python-service 2>/dev/null || echo "missing")
if [ "$status" != "running" ]; then
echo "Container verification failed. Current status: $status" >&2
nerdctl logs --tail 20 test-python-service
exit 1
fi
echo "Container healthy and active."Instruct the agent to run `nerdctl system prune` with `--dry-run` or check content store usage with `nerdctl system df` before completing storage cleanup tasks.
Running `nerdctl rm -f` without verifying container namespaces can accidentally remove active Kubernetes control-plane or worker pods if the agent switched into `k8s.io`.
Real-World Scenario: Triage and Deploy eStargz Workload in Kubernetes containerd Namespace
“Switch containerd namespace to k8s.io, list all failing containers, and deploy a diagnostic container using nerdctl run with estargz lazy pulling to ghcr.io/stargz-containers/alpine:latest.”
Runtime Troubleshooting & Failure Modes
Root Cause: The agent attempted to invoke nerdctl in rootless mode, but rootless containerd systemd service was not enabled or initialized for the current UID.
containerd-rootless-setuptool.sh install && systemctl --user start containerd.service && export CONTAINERD_ADDRESS=/run/user/$(id -u)/containerd/containerd.sockRoot Cause: Containerd configuration /etc/containerd/config.toml lacks the proxy plugin definition for stargz snapshotter, or containerd-stargz-grpc service is not active.
sudo systemctl restart stargz-snapshotter && nerdctl --snapshotter=overlayfs run --help > /dev/null || nerdctl infoFrequently Asked Questions (containerd & nerdctl Docker-Compatible Management SOP)
Q:Can I use containerd & nerdctl Docker-Compatible Management across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification. By placing the manifest in `.agents/skills/containerd-nerdctl-cli/SKILL.md` within your project repository, Codex, Claude Code, Cursor, and Windsurf can simultaneously parse the triggers and invoke the identical containerd management procedures.
Q:How does containerd & nerdctl Docker-Compatible Management prevent context window overflow during long agent sessions?
Rather than dumping verbose docker-to-containerd migration guides or deep containerd manuals into the conversational history, the skill introduces targeted frontmatter triggers and concise procedural commands. The agent only pulls the specific flags needed (e.g. `--snapshotter=stargz`, `--namespace`) during active execution.
Q:Does this skill require escalated root or container permissions?
Not necessarily. Nerdctl natively supports both rootful containerd and rootless containerd via `containerd-rootless.sh`. With a security score of 98/100, the skill functions securely in user-namespaced rootless mode without requiring host-level `sudo` privileges or insecure container capabilities.
Ready to equip your autonomous agent with containerd & nerdctl Docker-Compatible Management?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.