# Claude Code in Docker

> Run Claude Code in a container: EnvHaven's open-source image with Claude Code built in, a managed workspace with nothing to run, and the folders and keys a container of your own has to keep.

_Updated November 23, 2026 · Checked against Claude Code 2.1.308 in EnvHaven v1.9.0_

A container keeps whatever Claude Code does with full access away from your own files, which makes it the usual home for unattended runs. EnvHaven is built on that idea in two forms: a managed workspace, which is the container already running on a server of its own, and the open-source workspace image, which you run with Docker yourself.

## A managed workspace: nothing to run

1. Open your workspace in any browser. It is the EnvHaven container on its own always-on server, with an HTTPS address for what you build.
2. Tap **Launch**, choose Claude Code and tap **Sign in**: it opens claude.ai so you can approve the workspace, then takes the short code the page shows, so a Claude plan works with no API key. For an API key, choose **Set key** instead and paste `ANTHROPIC_API_KEY` or `CLAUDE_CODE_OAUTH_TOKEN`; the workspace keeps it write-only.
3. Start it with one tap: signed in, Claude Code gets a green dot in the Launch menu and an icon in the workspace's top bar. Support is built in (2.1.308), so there is nothing to install or update.
4. Give it a task. The image writes `defaultMode: "bypassPermissions"` into the workspace user's own settings, so `claude` starts without prompts, as an unprivileged user.

## The EnvHaven image, on your own Docker

The workspace image is MIT-licensed and ships Claude Code 2.1.308 beside 16 other agents. Its home is `/config`, so one volume keeps every agent's settings and sign-in when the container is replaced:

```bash
docker run -d \
  --name envhaven \
  -p 8443:8443 \
  -p 2222:22 \
  -e PASSWORD=password \
  -e SUDO_PASSWORD=password \
  -v envhaven-config:/config \
  ghcr.io/envhaven/envhaven:latest
```

Open `http://localhost:8443`, run `claude` in the terminal and sign in. The [self-hosted guide](https://envhaven.com/guides/self-hosted-dev-environment) covers SSH and Haven CLI against it.

## What a container for Claude Code has to keep

Claude Code keeps its settings in `~/.claude` and `~/.claude.json` ([source](https://code.claude.com/docs/en/authentication)). On Linux the sign-in is `~/.claude/.credentials.json`. `CLAUDE_CONFIG_DIR` moves it together with `.claude.json`, so pointing it at one volume keeps both.

In a container of your own, mount a volume at each of those paths so a rebuilt container stays signed in, or pass `ANTHROPIC_API_KEY` or `CLAUDE_CODE_OAUTH_TOKEN` as an environment variable instead of signing in.

## Full access inside the container

For one session:

```bash
claude --dangerously-skip-permissions
```

Or by permission mode:

```bash
claude --permission-mode bypassPermissions
```

Bypass mode runs every tool without asking, with two exceptions worth knowing. Claude Code refuses it as root or under sudo ("--dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons") unless it detects a recognized sandbox, and it ignores the setting in a project's `.claude/settings.json`. `rm` on critical paths still asks, with a two-minute countdown before it denies.

## Keep reading

- [Claude Code](https://envhaven.com/agents/claude-code)
- [Claude Code in the browser](https://envhaven.com/agents/claude-code/browser)
- [Claude Code on iPhone](https://envhaven.com/agents/claude-code/iphone)
- [Claude Code on iPad](https://envhaven.com/agents/claude-code/ipad)
- [Claude Code on Android](https://envhaven.com/agents/claude-code/android)
- [Claude Code on a Chromebook](https://envhaven.com/agents/claude-code/chromebook)
- [Coding agents in Docker](https://envhaven.com/agents/docker)

Source: https://envhaven.com/agents/claude-code/docker
