You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docker compose run --rm claude claude "explain this code"
66
99
```
67
100
68
-
### Run a Specific Command
101
+
### Resume a Conversation
69
102
70
103
```bash
71
-
#Run claude with arguments
104
+
#Continue from where you left off (requires persistent config)
72
105
docker run -it --rm \
73
106
-v $(pwd):/workspace \
107
+
-v ~/.claude:/home/coder/.claude \
74
108
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
75
109
ungb/claude-code \
76
-
claude "explain this codebase"
110
+
claude --resume
111
+
```
77
112
78
-
# Check version
79
-
docker run -it --rm ungb/claude-code claude --version
113
+
### Non-Interactive / CI Mode
80
114
81
-
# Run health check
115
+
```bash
116
+
# Run without prompts (for scripts/CI)
82
117
docker run -it --rm \
118
+
-v $(pwd):/workspace \
83
119
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
84
120
ungb/claude-code \
85
-
claude doctor
121
+
claude --yes "format all TypeScript files"
122
+
```
123
+
124
+
## Sharing Your Claude Configuration
125
+
126
+
The `~/.claude` directory contains your personal Claude Code configuration including custom slash commands, skills, agents, and settings. Mount it to use your customizations inside the container.
127
+
128
+
### What's in ~/.claude
129
+
130
+
```
131
+
~/.claude/
132
+
├── settings.json # Global settings and preferences
133
+
├── settings.local.json # Local overrides and permissions
134
+
├── commands/ # Custom slash commands (.md files)
135
+
│ ├── my-command.md
136
+
│ └── another-command.md
137
+
├── agents/ # Custom agents (.md files with YAML frontmatter)
138
+
│ ├── code-reviewer.md
139
+
│ └── debugger.md
140
+
└── .claude.json # MCP server configurations
86
141
```
87
142
143
+
### Mount Your Configuration
144
+
145
+
```bash
146
+
# Share your entire .claude folder (includes commands, agents, settings)
147
+
docker run -it --rm \
148
+
-v $(pwd):/workspace \
149
+
-v ~/.claude:/home/coder/.claude \
150
+
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
151
+
ungb/claude-code
152
+
```
153
+
154
+
### Use Custom Slash Commands
155
+
156
+
Once your `~/.claude` is mounted, your custom commands are available:
157
+
158
+
```bash
159
+
docker run -it --rm \
160
+
-v $(pwd):/workspace \
161
+
-v ~/.claude:/home/coder/.claude \
162
+
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
163
+
ungb/claude-code \
164
+
claude "/my-custom-command"
165
+
```
166
+
167
+
### Project-Specific Configuration
168
+
169
+
Projects can have their own `.claude/` directory with project-specific commands:
170
+
171
+
```bash
172
+
# Your project's .claude/ is automatically available at /workspace/.claude/
173
+
docker run -it --rm \
174
+
-v $(pwd):/workspace \
175
+
-v ~/.claude:/home/coder/.claude \
176
+
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
177
+
ungb/claude-code
178
+
```
179
+
180
+
## MCP (Model Context Protocol) Support
181
+
182
+
> **Warning**: MCP support in Docker containers is limited and may require additional configuration.
183
+
184
+
### Current Limitations
185
+
186
+
MCP servers may not work out of the box in Docker because:
187
+
188
+
1.**Stdio-based MCP servers** need the server binary installed inside the container
189
+
2.**Network-based MCP servers** need proper network configuration
190
+
3.**MCP servers that access local resources** (files, databases) need those resources available in the container
191
+
4.**Authentication** for MCP servers may not transfer into the container
192
+
193
+
### What Might Work
194
+
195
+
| MCP Type | Status | Notes |
196
+
|----------|--------|-------|
197
+
| HTTP/SSE servers (remote) | May work | Requires `--network host` or proper port mapping |
198
+
| Stdio servers (local) | Unlikely | Server must be installed in container |
199
+
| Servers needing local files | Partial | Files must be mounted into container |
200
+
| Servers with OAuth | Unlikely | Auth flow may not complete in container |
201
+
202
+
### Attempting MCP with Docker
203
+
204
+
If you want to try MCP servers:
205
+
206
+
```bash
207
+
# Mount MCP config and use host network
208
+
docker run -it --rm \
209
+
--network host \
210
+
-v $(pwd):/workspace \
211
+
-v ~/.claude:/home/coder/.claude \
212
+
-v ~/.claude.json:/home/coder/.claude.json:ro \
213
+
-e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
214
+
ungb/claude-code
215
+
```
216
+
217
+
### Building a Custom Image with MCP Servers
218
+
219
+
For stdio-based MCP servers, you'll need to build a custom image:
220
+
221
+
```dockerfile
222
+
FROM ungb/claude-code:latest
223
+
224
+
# Switch to root to install packages
225
+
USER root
226
+
227
+
# Example: Install an MCP server
228
+
RUN npm install -g @anthropic/mcp-server-example
229
+
230
+
# Switch back to coder user
231
+
USER coder
232
+
```
233
+
234
+
### MCP Investigation Needed
235
+
236
+
Full MCP support in Docker containers requires further investigation:
237
+
- Testing specific MCP servers for compatibility
238
+
- Network configuration for different MCP transport types
239
+
- Credential/auth forwarding for authenticated MCP servers
240
+
- Potential need for Docker-in-Docker for some servers
241
+
242
+
If you have insights or solutions for MCP in Docker, please open an issue or PR!
243
+
88
244
## Authentication
89
245
90
246
### Option 1: API Key (Recommended for Docker)
91
247
92
-
Get an API key from [Anthropic Console](https://console.anthropic.com/) and pass it as an environment variable:
248
+
Get an API key from [Anthropic Console](https://console.anthropic.com/):
93
249
94
250
```bash
95
251
-e ANTHROPIC_API_KEY=sk-ant-...
96
252
```
97
253
98
254
### Option 2: OAuth Login
99
255
100
-
For browser-based OAuth (requires host network):
256
+
OAuth login is a two-step process:
257
+
258
+
**Step 1: Login (once)**
101
259
102
260
```bash
261
+
# Login with browser-based OAuth (requires host network for callback)
103
262
docker run -it --rm \
104
263
--network host \
105
-
-v $(pwd):/workspace \
106
-
-v claude-config:/home/coder/.claude \
264
+
-v ~/.claude:/home/coder/.claude \
107
265
ungb/claude-code \
108
266
claude login
109
267
```
110
268
269
+
This opens a browser, authenticates, and saves tokens to `~/.claude/`.
270
+
271
+
**Step 2: Use normally**
272
+
273
+
```bash
274
+
# Now run without API key - tokens are in ~/.claude
275
+
docker run -it --rm \
276
+
-v $(pwd):/workspace \
277
+
-v ~/.claude:/home/coder/.claude \
278
+
ungb/claude-code
279
+
```
280
+
281
+
> **Note**: Mount `~/.claude` from your host so tokens persist between container runs.
282
+
111
283
## Volume Mounts
112
284
113
285
| Mount | Purpose |
114
286
|-------|---------|
115
287
|`/workspace`| Your project directory (required) |
116
-
|`/home/coder/.claude`| Claude config and cache (optional, for persistence) |
117
-
|`/home/coder/.ssh`| SSH keys for git operations (optional, read-only) |
0 commit comments