Docker-in-Docker¶
--dind gives a tool its own rootless Docker daemon in a per-run sidecar, never the host's socket, which would give the agent root on your machine. Use it when the agent needs to build images, run containers, use docker compose or test devcontainers. With the microsandbox runtime, the daemon runs inside the VM instead.
Usage¶
The Docker host must allow unprivileged user namespaces, the default on Docker Desktop and most Linux distributions.
agentic build claude --base docker # once: add the Docker CLI layer
agentic run --dind claude
Or per project, with [run.dind]:
[run.dind]
enabled = true
memory = "8g" # sidecar only
Inner containers' published ports are reachable from the tool at agentic-docker:<port>. To open one on your machine, forward a port.
With --proxy, pulls, builds and containers go through the allowlist. Docker Hub is allowed automatically; allow other registries yourself, e.g. allowed_hosts = ["ghcr.io"].
How it stays isolated¶
- Tool container: keeps all its restrictions, and only gains a client cert and the reserved
DOCKER_*env vars. - Rootless daemon: runs as your user in a user namespace, never
--privileged. Running agentic as root with--dindis refused. - Id mapping: files inner containers write to
/workspaceas root are owned by you. Other inner ids map to a range from 2,000,000,000 that no host account owns. - Sidecar privileges: only the sidecar gets namespace-scoped capabilities, unconfined AppArmor and
/dev/net/tun, to create the user namespace. - Seccomp: Docker's default profile, minus kernel interfaces nested containers don't need (
bpf,perf_event_open,syslog, ...). Keyring syscalls stay blocked. - Image:
agentic-dind, built locally fromdocker:<version>-dind-rootlesswithout setuid/setgid bits, rebuilt with a fresh pull at least weekly. - Mutual TLS: per-run throwaway certs; the CA key never touches disk. Inner containers can't drive the daemon unless they mount its socket or certs.
- Filesystem: the daemon sees only
/workspace, and read-only mounts under it stay read-only. - Cleanup: images, containers, volumes, certs and Docker config (including
docker logincredentials) are removed when the run ends, also after a crash. - Network: the sidecar shares the tool's run network: direct internet without
--proxy, only the proxy with it.
Limitations¶
- Inner containers get namespace-scoped
CAP_SYS_ADMIN/CAP_NET_ADMIN, which exposes kernel interfaces (nf_tables, mounts, nested user namespaces) a plain container can't reach. Keep the host kernel patched. - The agent can push to an allowed registry.
- The sidecar's limits default to the tool's, so a run can use up to twice them. Images and volumes use the Docker host's disk with no size limit.
- An inner container can read the sidecar's own files, including its TLS key.
- Inner networks use
/24subnets from10.200.0.0/16(or10.201/10.202when the run network overlaps), so inner containers can't reach hosts in that range. - Proxy-injected credentials don't work in inner containers.