Sandboxed Docker environment for running CLI coding agents with network restrictions and host UID mapping.
Supported agents: Claude Code, Codex, Aider, Gemini CLI, OpenCode — and easy to add more.
- Runs any CLI agent inside an Ubuntu 24.04 container
- Maps host user UID/GID so file permissions stay correct
- Firewall (iptables) limits outbound traffic to:
- DNS
- Agent-specific API hosts (e.g.
api.anthropic.com) - Shared domains (
registry.npmjs.org,github.com,pypi.org, etc.) - Everything else is blocked
- Mounts the workspace and agent config from the host
Build the image:
./boxer buildRun Claude Code (default agent):
./boxerRun a different agent:
./boxer codex
./boxer aider
./boxer gemini
./boxer opencodeOverride the command (e.g. open a shell with agent config mounted):
./boxer claude -- bash- boxer — Python CLI that reads agent configs from
agents/*.yaml, builds docker arguments (mounts, allowed hosts, command), and launches the container - docker/entrypoint.sh — initializes the firewall as root, then drops to the non-root user via
gosu - docker/init-firewall.sh — sets up iptables rules from
$ALLOWED_HOSTSto restrict outbound network access
Create agents/<name>.yaml:
cmd: my-agent --flags
hosts:
- api.example.com
mounts:
- ~/.config/my-agent
- ~/.my-agent-rc:rocmd— the command to run inside the containerhosts— API hosts to allow through the firewallmounts— bind mounts from host; paths starting with~/expand to$HOME, append:rofor read-only
Shared domains in allowed_domains.txt are automatically included for all agents.
Then run: ./boxer <name>