2026-04-14 20:11:24 +02:00
# docker-claude
2026-04-15 22:41:28 +02:00
Runs [Claude Code ](https://claude.ai/code ) inside an isolated Docker environment with a proxy sidecar for controlled egress. Claude cannot access the host filesystem or network directly.
2026-04-14 20:11:24 +02:00
2026-04-16 10:13:34 +02:00
## Quick Start
2026-04-16 10:16:23 +02:00
**1. Install a Docker runtime**
2026-04-16 10:13:34 +02:00
2026-04-16 10:16:23 +02:00
Pick the free, open-source option for your platform:
| Platform | Recommended | Alternative |
|---|---|---|
| macOS | [Rancher Desktop ](https://rancherdesktop.io/ ) (GUI) | [Colima ](https://github.com/abiosoft/colima ) (CLI): `brew install colima docker docker-compose && colima start` |
| Linux | Docker Engine: `curl -fsSL https://get.docker.com \| sh` | [Rancher Desktop ](https://rancherdesktop.io/ ) |
| Windows | [Rancher Desktop ](https://rancherdesktop.io/ ) (GUI) | WSL2 + Docker Engine (see below) |
> **Note:** Docker Desktop is not listed — it requires a commercial licence for business use.
2026-04-16 10:13:34 +02:00
**2. Download this repo**
Clone or download and unzip this repository somewhere on your machine.
**3. Run setup**
- **macOS / Linux:** Open a terminal, navigate to the folder, and run:
```bash
./setup.sh
```
- **Windows:** Double-click `launch.bat` — it will run setup automatically on first launch.
Setup will ask how you want to authenticate (API key, subscription token, or browser login) and save your settings.
**4. Start Claude**
- **macOS / Linux:** Double-click `launch.sh` , or run it from a terminal:
```bash
./launch.sh
```
A folder picker will appear — select the project you want Claude to work on.
- **Windows:** Double-click `launch.bat` .
---
2026-04-14 20:11:24 +02:00
## Architecture
```
2026-04-14 22:25:38 +02:00
┌──────────────────────────────────────────────────────────┐
│ Host machine │
│ │
│ claude.sh (control script) │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Docker: claude-secure │ │
│ │ │ │
2026-04-15 22:41:28 +02:00
│ │ ┌─────────────┐ claude-internal │ │
│ │ │ claude │ (internal: true) │ │
│ │ │ (UID 1000) │──────────────► ┌──────────┐ │ │
│ │ └─────────────┘ │ proxy │ │ │
│ │ │ (UID 13) │ │ │
│ │ └────┬─────┘ │ │
│ │ proxy-external │ │
2026-04-14 22:25:38 +02:00
│ └──────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ internet (allowlisted) │
└──────────────────────────────────────────────────────────┘
2026-04-14 20:11:24 +02:00
```
2026-04-14 22:50:59 +02:00
- **`claude` ** — Claude Code CLI (`node:20-alpine` ), runs as the built-in `node` user (UID 1000), on `claude-internal` only
2026-04-14 22:40:57 +02:00
- **`proxy` ** — Squid forward proxy (`alpine:3.21` ), bridges `claude-internal` ↔ internet with egress allowlist
2026-04-14 22:25:38 +02:00
- **`claude-internal` ** — `internal: true` ; no default gateway, containers cannot reach the internet directly
- **`proxy-external` ** — Standard bridge; proxy sidecar only
2026-04-14 20:11:24 +02:00
## Prerequisites
2026-04-16 10:16:23 +02:00
A Docker runtime with Compose support. Choose a free, open-source option:
- **macOS:** [Rancher Desktop ](https://rancherdesktop.io/ ) or [Colima ](https://github.com/abiosoft/colima )
- **Linux:** [Docker Engine CE ](https://docs.docker.com/engine/install/ ) (`curl -fsSL https://get.docker.com | sh` )
- **Windows:** [Rancher Desktop ](https://rancherdesktop.io/ ) or WSL2 + Docker Engine
> Docker Desktop is not recommended — it requires a commercial licence for business use.
2026-04-14 20:11:24 +02:00
2026-04-14 22:47:04 +02:00
## Authentication
2026-04-16 10:13:34 +02:00
Three options — `./setup.sh` will guide you through picking one:
2026-04-14 22:47:04 +02:00
### Option 1 — API key
```bash
ANTHROPIC_API_KEY=sk-ant-...
```
2026-04-16 10:13:34 +02:00
Get a key at [console.anthropic.com ](https://console.anthropic.com/settings/keys ).
2026-04-14 22:47:04 +02:00
### Option 2 — OAuth token (subscription, headless-friendly)
Run this **on your host** (not inside the container) to generate a 1-year token:
```bash
claude setup-token
```
2026-04-16 10:13:34 +02:00
Then paste the token into setup, or set it manually in `.env` :
2026-04-14 22:47:04 +02:00
```bash
CLAUDE_CODE_OAUTH_TOKEN=...
```
### Option 3 — Browser OAuth (interactive)
Leave both keys unset. On first run, Claude Code will print a login URL.
2026-04-16 10:13:34 +02:00
Port 54545 must be reachable from your browser for the OAuth callback.
## Usage
### Normal use
2026-04-14 22:47:04 +02:00
```bash
2026-04-16 10:13:34 +02:00
./launch.sh # folder picker → starts Claude in the selected directory
2026-04-14 22:47:04 +02:00
```
2026-04-16 10:13:34 +02:00
### CLI / power users
2026-04-14 20:11:24 +02:00
```bash
2026-04-15 08:10:44 +02:00
cd ~/myproject
2026-04-14 20:11:24 +02:00
./claude.sh start
2026-04-14 22:25:38 +02:00
./claude.sh stop # Stop and remove all containers
2026-04-15 17:02:43 +02:00
./claude.sh update # Pull latest images from the registry
2026-04-14 22:25:38 +02:00
./claude.sh logs # Tail proxy logs
./claude.sh status # Show container status
./claude.sh shell # Debug bash shell in the Claude container
2026-04-14 20:11:24 +02:00
```
2026-04-16 10:16:23 +02:00
### Windows: WSL2 + Docker Engine (alternative to Rancher Desktop)
1. Install [WSL2 ](https://learn.microsoft.com/en-us/windows/wsl/install ): `wsl --install` in PowerShell
2. Open the Ubuntu terminal and run:
```bash
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
```
3. Log out and back in, then run `launch.bat` as usual.
2026-04-15 17:02:43 +02:00
### Building locally
```bash
./build.sh # build with layer cache
./build.sh --no-cache # force full rebuild
```
2026-04-14 20:11:24 +02:00
## Egress allowlist
Edit `proxy/squid.conf` and add domains to the `allowed_sites` ACL:
2026-04-14 22:25:38 +02:00
```
2026-04-14 20:11:24 +02:00
acl allowed_sites dstdomain api.anthropic.com
acl allowed_sites dstdomain statsig.anthropic.com
2026-04-14 22:25:38 +02:00
# acl allowed_sites dstdomain api.github.com
2026-04-14 20:11:24 +02:00
# acl allowed_sites dstdomain registry.npmjs.org
```
2026-04-14 22:25:38 +02:00
Rebuild after changes:
2026-04-14 20:11:24 +02:00
```bash
./claude.sh stop & & ./claude.sh start
```
## Security controls
2026-04-15 22:41:28 +02:00
| Control | claude | proxy |
2026-04-14 20:11:24 +02:00
|---|---|---|
2026-04-14 22:50:59 +02:00
| Non-root user | UID 1000 (`node` , built into base image) | `squid` user |
2026-04-14 20:11:24 +02:00
| `no-new-privileges` | yes | yes |
| All capabilities dropped | yes | yes |
| Direct internet access | no (`internal` network only) | allowlisted only |
2026-04-15 22:41:28 +02:00
| Host filesystem | CWD mounted as `/workspace` | none |
2026-04-14 20:11:24 +02:00
| Docker socket | not mounted | not mounted |