Notes on Containerized/Isolated Agents

Published on –

tl;dr – Some notes and links on containerized/isolated coding agents - bonus: my docker sandbox recipe


I have to put my money where my mouth is. Since I’ve been ranting about MCP and security in the post about “MCP in experimentation or how I trust the trust of others”. Having a docker container where I run the MCP tool in was not as straight forward as I thought. It worked somehow but also became annoying to maintain volumes in that one string to make this feasible. I dropped that and went on with my live.

But then I have been dabbling with agents in containers recently and here are some nice things I found.

Docker Sandbox Recipes

Run Go dev env for claude:

# ABOUTME: Development container for docker sandbox, adds Go toolchain for Pi development
# ABOUTME: Extends official claude code sandbox template with Go and dev tools

FROM docker/sandbox-templates:claude-code

# Create sandbox lock directory
RUN mkdir -p /home/agent/.docker/sandbox/locks

# Install Go and dev tools
RUN <<EOF
sudo apt-get update && sudo apt-get install -y \
	golang-go \
	fish \
	magic-wormhole \
	tmux \
	vim \
	bat \
	lsd \
	zoxide \
	&& sudo rm -rf /var/lib/apt/lists/*
EOF

ENV GOPATH=/home/agent/go
ENV PATH=$PATH:/home/agent/go/bin

Build the image

docker build my-template .

Use the sandbox with some local ~/.claude folders mounted as read only so the agent behaves more like my local agent. You still will have to login within the container with your credentials or provide a API key.

# Run claude in sandbox with this project
docker sandbox run -t my-template -w . \
  -v ~/.claude/CLAUDE.md:/home/agent/.claude/CLAUDE.md:ro \
  -v ~/.claude/plugins:/home/agent/.claude/plugins:ro \
  -v ~/.claude/commands:/home/agent/.claude/commands:ro \
  claude
# Continue previous session
docker sandbox run -t creatureone-dev -w . claude -c

If you do changes to the template you need to remove it first.

# If you rebuild the image, remove the old sandbox first
docker sandbox ls
docker sandbox rm <sandbox-id>