Skip to content

Commit 83698e9

Browse files
Syaticlaude
andcommitted
Use bind mounts for Claude/Codex auth persistence
Named volumes get wiped by `docker compose down -v`, forcing re-authentication every time. Bind-mount ~/.claude and ~/.codex to the host instead so credentials survive container cleanup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Entire-Checkpoint: 6fb6bfc15555
1 parent e1620ac commit 83698e9

3 files changed

Lines changed: 10 additions & 36 deletions

File tree

README.md

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@ services:
1414
- .:/workspace
1515
- /var/run/docker.sock:/var/run/docker.sock # host Docker access
1616
- ${HOME}/.gitconfig:/home/agent/.gitconfig:ro # git config
17-
- claude-home:/home/agent/.claude
18-
- codex-home:/home/agent/.codex
17+
- ${HOME}/.claude:/home/agent/.claude
18+
- ${HOME}/.codex:/home/agent/.codex
1919
- mise-data:/home/agent/.local/share/mise
2020
env_file:
2121
- .env
2222
extra_hosts:
2323
- "host.docker.internal:host-gateway"
2424

2525
volumes:
26-
claude-home:
27-
codex-home:
2826
mise-data:
2927
```
3028
3129
- **Docker socket**: allows the container to control host Docker (`docker compose run`, `docker exec`, etc.). Remove if not needed.
32-
- **Named volumes**: persist Claude Code/Codex session history and mise-installed runtimes across container recreations. Only cleared by `docker compose down -v`.
30+
- **Bind mounts (`~/.claude`, `~/.codex`)**: persist auth and session data on the host. Survives `docker compose down -v`.
31+
- **Named volume (`mise-data`)**: persists mise-installed runtimes across container recreations. Cleared by `docker compose down -v`.
3332
- **gitconfig**: mounts host git config (read-only) so `git commit` and `git push` work inside the container.
3433

3534
Start the container and connect:
@@ -50,33 +49,10 @@ With [sheldon](https://github.com/rossmacarthur/sheldon), add to `~/.config/shel
5049
github = "Syati/agent-stack"
5150
```
5251

53-
Or add the function directly to your `~/.zshrc`:
52+
Or source the plugin directly in your `~/.zshrc`:
5453

5554
```bash
56-
agent() {
57-
local env_file=${HOME}/.agent-stack.env
58-
local env_args=()
59-
if [[ -f "$env_file" ]]; then
60-
if command -v op &>/dev/null; then
61-
while IFS= read -r line; do
62-
[[ -n "$line" && "$line" != \#* ]] && env_args+=(-e "$line")
63-
done < <(op inject -i "$env_file")
64-
else
65-
env_args=(--env-file "$env_file")
66-
fi
67-
fi
68-
69-
docker run -it \
70-
-v $(pwd):/workspace \
71-
-v /var/run/docker.sock:/var/run/docker.sock \
72-
-v ${HOME}/.gitconfig:/home/agent/.gitconfig:ro \
73-
-v agent-claude-home:/home/agent/.claude \
74-
-v agent-codex-home:/home/agent/.codex \
75-
-v agent-mise-data:/home/agent/.local/share/mise \
76-
${env_args[@]} \
77-
--add-host host.docker.internal:host-gateway \
78-
ghcr.io/syati/agent-stack zsh
79-
}
55+
source /path/to/agent-stack/agent-stack.plugin.zsh
8056
```
8157

8258
Multiple instances can run in parallel — each `agent` call creates a separate container. Use [git-wt](https://github.com/k1LoW/git-wt) worktrees to avoid file conflicts when multiple agents work on the same repo.

agent-stack.plugin.zsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ agent() {
1515
-v $(pwd):/workspace \
1616
-v /var/run/docker.sock:/var/run/docker.sock \
1717
-v ${HOME}/.gitconfig:/home/agent/.gitconfig:ro \
18-
-v agent-claude-home:/home/agent/.claude \
19-
-v agent-codex-home:/home/agent/.codex \
18+
-v ${HOME}/.claude:/home/agent/.claude \
19+
-v ${HOME}/.codex:/home/agent/.codex \
2020
-v agent-mise-data:/home/agent/.local/share/mise \
2121
${env_args[@]} \
2222
--add-host host.docker.internal:host-gateway \

compose.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ services:
77
- .:/workspace
88
- /var/run/docker.sock:/var/run/docker.sock
99
- ${HOME}/.gitconfig:/home/agent/.gitconfig:ro
10-
- claude-home:/home/agent/.claude
11-
- codex-home:/home/agent/.codex
10+
- ${HOME}/.claude:/home/agent/.claude
11+
- ${HOME}/.codex:/home/agent/.codex
1212
- mise-data:/home/agent/.local/share/mise
1313
env_file:
1414
- .env
@@ -17,6 +17,4 @@ services:
1717
working_dir: /workspace
1818

1919
volumes:
20-
claude-home:
21-
codex-home:
2220
mise-data:

0 commit comments

Comments
 (0)