Why a container
In a plain terminal, an agent asks before most commands, because it can reach everything you can. In a container it reaches the project and what you mount, not the rest of your Mac, so you can let it work without prompts. It still has the network and any credential inside the container. Built from the same image as your CI, it also has the same tools.
By hand
The devcontainer CLI builds and starts a container from .devcontainer/devcontainer.json. Install the agent in the container and give its config a volume of its own. Your Mac’s sign-in is in the Keychain, which a container cannot read, so sign in once inside with the first exec below, then quit; the volume keeps it across rebuilds. Other agents follow the same pattern, each with its own folder.
{
"image": "mcr.microsoft.com/devcontainers/typescript-node:22",
"containerEnv": { "CLAUDE_CONFIG_DIR": "/home/node/.claude" },
"mounts": [
"source=claude-config,target=/home/node/.claude,type=volume"
],
"postCreateCommand": "sudo chown node /home/node/.claude && npm install -g @anthropic-ai/claude-code"
}npm install -g @devcontainers/cli devcontainer up --workspace-folder . devcontainer exec --workspace-folder . claude devcontainer exec --workspace-folder . claude --dangerously-skip-permissions
Mount only the folders the agents need. Mounting ~/.ssh or your git credentials gives the agent your push access along with them.
Worktrees in a container
A worktree’s .git is a file that points at the main repository by its absolute path on the Mac. Inside a container that path does not exist, and git fails with “not a git repository”. Mount the main repository at the same absolute path in the container, and the worktrees’ folder too if it is outside it. Run git status in a worktree inside the container to check.
With Dockazor
Per project, Dockazor runs the agents in a container under Docker Desktop or OrbStack. Bring your own devcontainer.json, or let Dockazor write one. Your image needs Node; Dockazor installs the built-in agents you turn on for the project, and an agent you add goes in your Dockerfile.
| In the container | Stays on your Mac |
|---|---|
| Your agents and their sign-ins | Your SSH keys |
| The project and its worktrees | Your git credentials |
| Other projects you let it read, read-only | Your Keychain |
Your SSH keys, git credentials and Keychain stay on the Mac unless your own devcontainer.json mounts them. In the container, Claude Code edits files and runs commands without asking you first.
The container is the wall. Beside it, Dockazor refuses an agent’s pushes and its changes to other branches: a second net for mistakes.