Document data persistence and storage locations

This commit is contained in:
2026-04-10 10:00:51 +02:00
parent 4b7b8a0c4b
commit ca5efe1007
2 changed files with 32 additions and 8 deletions
+18 -8
View File
@@ -103,18 +103,28 @@ opencode
| `GIT_USER_NAME` | Git commit author name |
| `GIT_USER_EMAIL` | Git commit author email |
## Volumes
## Data Storage and Persistence
| Host Path | Container Path | Purpose |
|---|---|---|
| Your project directory | `/workspace` | Code you want to work on |
| `~/.ssh` | `/home/developer/.ssh:ro` | SSH keys for git (read-only) |
| (optional) `~/.aws` | `/home/developer/.aws:ro` | AWS credentials/config |
| (optional) Custom config | `/home/developer/.config/opencode/opencode.json:ro` | Full opencode config with MCP servers, etc. |
Understanding what survives container restarts and what doesn't:
| Path in container | Source | Survives restart? | Contains |
|---|---|---|---|
| `/workspace` | Host bind mount | ✅ Yes — lives on host | Your project files |
| `/home/developer/.ssh` | Host bind mount (ro) | ✅ Yes — lives on host | SSH keys |
| `/home/developer/.local/share/opencode` | Named volume (if configured) | ✅ Yes — Docker volume | Session history, memory, auth tokens |
| `/home/developer/.config/opencode/opencode.json` | Generated by entrypoint | ❌ No — regenerated each start | Provider config, MCP server definitions |
| `/home/developer/.aws` | Host bind mount (if configured) | ✅ Yes — lives on host | AWS credentials/SSO cache |
### Key points
- **Project files** (`/workspace`) are always safe — they're your host filesystem.
- **opencode config** is auto-generated from `OPENCODE_PROVIDER` env var on each start. It only sets provider and model — no MCP servers. To persist MCP server config, mount your own config file (see Custom opencode Config below).
- **opencode data** (session history, memory) is lost with `--rm` unless you add a named volume.
- **AWS SSO tokens** are stored inside the container and lost on restart. Re-run `aws sso login` after restarting.
### Persisting opencode data
To keep opencode state (session history, memory) between runs, add a named volume:
Add a named volume to keep session history and memory between runs:
```bash
docker run -it --rm \