GuidesHosting choices

Dev containers for coding agents: Claude Code, Codex, OpenCode

What a dev container is, running one on a server with the devcontainer CLI, Claude Code's official feature and firewall, Codex and OpenCode, and the limits.

December 2, 2026The Everpod team
The short answer

A dev container is a Docker container described by a .devcontainer/devcontainer.json file in your project, under the open Dev Container spec at containers.dev. The file names an image or Dockerfile, the features (packaged install scripts) to add, mounts, environment and setup commands. On a server with no editor, install the Dev Container CLI (npm install -g @devcontainers/cli, version 0.91.0 as of December 2026), then run devcontainer up --workspace-folder . and devcontainer exec --workspace-folder . claude. Anthropic publishes an official Claude Code feature and a reference container with an outbound firewall; OpenAI documents running Codex in a dev container but publishes no feature, and OpenCode documents neither. Mount a named volume over each agent’s config folder so the sign-in survives a rebuild. The container limits what the agent reaches, not what it can steal from inside: both makers warn that credentials in the container are exposed once the approval checks are off.

What a dev container is made of

The Development Container Specification calls itself “an open specification for enriching containers with development specific content and settings.” In practice it is one JSON file the tools agree on. The properties that matter for an agent, from the devcontainer.json reference:

PropertyWhat it doesWhy an agent setup cares
image or build.dockerfile
The base the container starts fromYour toolchain, so the agent can run the tests
features
Feature IDs and options added to the containerThe usual way to install the agent itself
mounts
Extra mounts, in the syntax of Docker’s --mountThe volume that keeps the agent’s sign-in and history
containerEnv
Environment variables for the whole containerPointing the agent at that volume
remoteUser
The user tools run as insideClaude Code refuses to skip its checks as root
runArgs, capAdd
Extra docker run arguments and Linux capabilitiesWhat a firewall inside the container needs, and what quietly widens it
postCreateCommand, postStartCommand
Commands run once after creation, and on every startInstalling an agent with no feature; starting a firewall
initializeCommand
A command run on the host during initializationRead it before opening someone else’s repository

A feature, per the features spec, is a folder with “at least a devcontainer-feature.json and install.sh entrypoint script”, published to an OCI registry and referenced as <registry>/<namespace>/<feature>:<version>. Its install.sh runs as root while the image is built, so adding a feature is running a stranger’s script as root in your container. That matters for the next section.

Who publishes a feature for which agent

The features index lists every collection someone has registered, and says plainly that “inclusion in this index does not imply that the Dev Container maintainers have security-reviewed or endorsed their code.” Read on December 2, 2026:

A community feature is a convenience, not a requirement. Each of these agents has an official install command that runs fine as a postCreateCommand, which keeps the install in your own file, uses the maker’s own command, and runs as your user rather than as root.

Running one on a server without VS Code

Editors with dev container support (VS Code, JetBrains IDEs, Cursor, GitHub Codespaces) build and attach for you. On a Linux server over SSH, the Dev Container CLI does the same from a terminal, with Docker already installed. Its npm package needs Node.js 20 or later (and Python and a C compiler to build one dependency); the standalone script brings its own Node.js:

curl -fsSL https://raw.githubusercontent.com/devcontainers/cli/main/scripts/install.sh | sh
export PATH="$HOME/.devcontainers/bin:$PATH"
devcontainer --version
Copied

Add the export line to your ~/.bashrc to keep it. Then, from the project folder that holds .devcontainer/:

devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . bash
Copied

A devcontainer.json for Claude Code and Codex

This one starts from Microsoft’s Ubuntu base image, whose vscode user is not root, installs Claude Code with Anthropic’s feature and Codex with OpenAI’s install script, and gives each agent its own volume per project. Save it as .devcontainer/devcontainer.json:

{
  "name": "agents",
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu24.04",
  "features": {
    "ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {}
  },
  "remoteUser": "vscode",
  "mounts": [
    "source=claude-${devcontainerId},target=/home/vscode/.claude,type=volume",
    "source=codex-${devcontainerId},target=/home/vscode/.codex,type=volume"
  ],
  "containerEnv": {
    "CLAUDE_CONFIG_DIR": "/home/vscode/.claude",
    "CODEX_HOME": "/home/vscode/.codex"
  },
  "postCreateCommand": "sudo chown vscode:vscode /home/vscode/.claude /home/vscode/.codex && curl -fsSL https://chatgpt.com/codex/install.sh | sh"
}
Copied

That base image gives vscode sudo access, which is convenient and also means the agent can become root inside the container. For a container you mean as a boundary, build your own image the way Anthropic’s reference does: a non-root user whose sudo rights cover only the firewall script.

Signing in once, and keeping it

Every rebuild throws away the container’s home directory. What each agent needs on a volume:

AgentWhere its sign-in livesWhat to set
Claude Code
~/.claude (credentials, settings, history) and ~/.claude.json outside it (account, per-project trust, the record that setup is done)Volume at ~/.claude and CLAUDE_CONFIG_DIR to the same path, so .claude.json lands inside the volume. Without the variable, setup repeats after every rebuild.
Codex
auth.json in CODEX_HOME (default ~/.codex), a plain-text file, or a system credential store where one is available and Codex is set to use itVolume at ~/.codex; set CODEX_HOME if you mount it elsewhere
OpenCode
Its database, ~/.local/share/opencode/opencode.db, which holds saved keys and logins in version 2 (older versions used auth.json beside it), with config in ~/.config/opencodeVolumes at both folders

There is no browser in the container. Claude Code prints a login URL above its paste prompt: open it on your own computer, sign in, and paste the code it shows back into the terminal. Codex has codex login --device-auth, which per OpenAI’s authentication page has to be enabled first in your ChatGPT security settings (or by a workspace admin). Do either once, through devcontainer exec, and the volume carries it from then on. For unattended use with a token instead of a login, see Claude Code in Docker, which covers passing one without baking it into the image.

Running without approval prompts inside it

This is usually why the container exists. Both makers point the no-prompt modes at a container:

Both warnings say the same thing. Anthropic: with the checks off, “dev containers do not prevent a malicious project from exfiltrating anything accessible inside the container, including the Claude Code credentials stored in ~/.claude.” OpenAI: “a malicious project can exfiltrate anything available inside the devcontainer, including Codex credentials.” Use it with repositories you trust, mount no ~/.ssh or cloud credential files, and prefer short-lived or repository-scoped tokens. How the no-prompt modes compare with the safer middle settings is in running Claude Code and Codex without permission prompts.

Anthropic’s firewall, read closely

The reference container in anthropics/claude-code/.devcontainer is the only dev container any of these three agents’ makers publishes, and it controls egress. It adds NET_ADMIN and NET_RAW to the container and runs init-firewall.sh as its postStartCommand, on every start. Its default is to drop everything and reject other outbound traffic. What it lets through matters more than the default:

claude.ai and platform.claude.com are not on the list, and Anthropic’s network requirements name both for signing in with a Claude account and for refreshing the token. Add them if a subscription login fails behind the firewall. Codex and OpenCode need their own providers’ hosts added the same way. The script also depends on the agent not being able to undo it: the reference gives its user sudo for the firewall script only, while an image whose user has general sudo, plus NET_ADMIN, leaves the rules one command away from the agent.

What a dev container does not do

Run Claude Code, Codex, OpenCode, Pi, Hermes or OpenClaw on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.