Coding agents need a workbench of their own
An agent that runs commands belongs in a container: the same environment for everyone, its own keys, and a mistake only hits what is in there.
A coding agent does more than read code. It installs packages, runs tests, starts servers, and writes files. Whatever its process can reach, it can also change: the SSH key in the home directory, the credentials of the cloud CLI, the wrong directory. So the question is not whether you trust the agent, but what lies within its reach.
What the container solves
A container of its own for agent work brings three things:
- The same environment. Runtime, compilers, and tools are written down in the Dockerfile, and that file lives in the repository. The agent works with the same versions as the team and as CI.
- Limited reach. Only the project is in the container. A wrong
rm -rfhits the working copy, not the machine. - One place. If the container runs on a server, the same environment is reachable over SSH from any device, and long tasks keep running in a tmux session when the laptop is closed.
What goes in and what stays out
What goes in: the project's tools, a working copy, and a key of its own with exactly the rights the task needs. That means a deploy key for one repository instead of the personal key for all of them.
Personal SSH keys, production access, and admin tokens stay outside. API keys come in as environment variables from a file that is not in the repository.
services:
workbench:
build: .
# not in the repository
env_file: .env
ports:
# SSH, key only
- "2222:2222"
volumes:
# working copies
- workspace:/workspace
# tool settings
- config:/home/dev/.config
volumes:
workspace:
config:
What survives a rebuild
The container is disposable, the work in it is not. Working copies and tool settings therefore live on volumes. Everything else is in the Dockerfile. Whatever the agent installs by hand is gone after the next rebuild. That is intended: the environment stays what the repository describes.
Where the boundary ends
A container is not a virtual machine. It shares the kernel with the host. Anyone who passes the Docker socket into it or starts it with --privileged gives the boundary up again. Two more things the container does not solve:
- Network. The agent reaches what the container reaches. Outgoing connections can be restricted. Without that restriction an agent can send data out.
- Third-party text. A web page or an issue can contain instructions the agent takes for its task. No environment helps against that, only minimal permissions and a person's approval before anything that cannot be taken back.
So the container does not replace review. It keeps a mistake small.
The effort
A Dockerfile, a Compose file, a small server. Florian Zeba describes a complete setup with Dockerfile, key management, and deployment on his blog: Cloud-Based Agentic Dev Container: Claude Code, Codex, and OpenCode in One. The rules for keys are stricter here than there.