This file documents the OpenCode configuration for the opencode-docker project.
opencode-docker is a hardened Docker wrapper for OpenCode that provides:
- Isolated workspace access via bind mounts
- Credential opt-in mechanisms for AWS, GitHub, GitLab, and Terraform Cloud
- GitHub auth proxy sidecar for secure token handling
- Private package registry support
- File ownership preservation (host UID/GID mapping)
- Security hardening via capability dropping and no-new-privileges
The main OpenCode agent runs inside the container with access to mounted workspaces and opted-in credentials.
- Host:
~/.config/opencode/ - Container:
/root/.config/opencode/
Mounted items from host config:
agents/- Custom agent definitionsskills/- Custom skillscommands/- Slash commandsprompts/- Custom promptsAGENTS.md- Global preferencesopencode.docker.json- Container-specific OpenCode config (copied toopencode.json)
Container-specific settings are managed via opencode.docker.json, which is copied to opencode.json in the container at startup. This allows in-session config changes to persist for the container's lifetime while being re-seeded from the host on each start.
See examples/opencode.docker.json for a starting configuration.
- Host filesystem outside passed workspaces
- Host
~/.aws/credentials(long-lived keys) - Host credential directories (read-only when opted in)
- Workspace directories (read-write unless
--ro) - Short-lived AWS SSO bearer tokens
- GitHub tokens (via proxy sidecar or direct forwarding)
- GitLab tokens
- Terraform Cloud tokens
- Private registry configuration files
Named volumes carry state across runs (unless --ephemeral):
opencode-root-/root(OAuth tokens, shell history)opencode-home-/root/.config/opencode(conversation history, settings)
opencode-docker ~/repo-a ~/repo-bopencode-docker --aws --gh ~/repoopencode-docker --ephemeral --ro ~/untrusted-repoopencode-docker --iterm ~/repo # iTerm2 native panes
opencode-docker --tmux ~/repo # Plain tmux splitsExtend the base image with project-specific tooling:
FROM opencode:local
RUN apt-get install -y my-toolThen use with:
OPENCODE_DOCKER_IMAGE=my-opencode:local opencode-docker ~/repo