Docker container for OpenCode - the open source AI coding agent.
- OpenCode AI - Pinned to a specific version (
.opencode-version) for reproducible builds - Node.js - Latest from node:alpine base image, for npm-based MCP servers (
npx) - Python 3 + pip - For Python-based MCP servers (
uvx) and pip packages - uv - Fast Python package manager
- git - Version control
- ripgrep (rg) - Fast code search
- jq - Command-line JSON processor
- curl - HTTP requests
- bash - Shell scripting
- tar - Archive extraction
- Alpine Linux - Minimal base image
Minimal (ephemeral - data lost on restart):
docker run -d -p 4096:4096 -e OPENCODE_HOSTNAME=0.0.0.0 vinnyahh/opencode-box:latest
⚠️ Security:OPENCODE_HOSTNAME=0.0.0.0is required for the published port to be reachable, but it exposes an unauthenticated agent with full file & shell access. Run it only on a trusted local network, or setOPENCODE_SERVER_PASSWORD.
With persistence:
docker run -d \
-p 4096:4096 \
-e OPENCODE_PORT=4096 \
-e OPENCODE_HOSTNAME=0.0.0.0 \
-e OPENCODE_CONFIG=/config/opencode.json \
-v ./config:/config \
-v ./data:/data \
-v ./projects:/projects \
vinnyahh/opencode-box:latestAccess at http://localhost:4096
| Variable | Description | Default |
|---|---|---|
OPENCODE_PORT |
Server port | 4096 |
OPENCODE_HOSTNAME |
Server hostname | 127.0.0.1 |
OPENCODE_CONFIG |
Path to config file | - |
OPENCODE_SERVER_PASSWORD |
Basic auth password | - |
| Path | Description |
|---|---|
/config |
OpenCode config, agents, commands |
/data |
Sessions, auth, logs |
/projects |
Your project files |
Expected structure:
config/
├── opencode.json # Main config file
├── agents/ # Custom agents
├── commands/ # Custom commands
├── plugins/ # Custom plugins
├── themes/ # Custom themes
├── tools/ # Custom tools
├── skills/ # Custom skills
└── modes/ # Custom modes
data/
├── auth.json # API credentials (auto-generated)
├── mcp-auth.json # MCP OAuth tokens (auto-generated)
├── sessions/ # Conversation history
├── snapshots/ # Session checkpoints
└── log/ # Log files
projects/
└── (your code) # Your project files
This container supports running MCP (Model Context Protocol) servers:
| MCP Server Type | Runtime | Example Command |
|---|---|---|
| Node.js packages | npx |
npx -y @modelcontextprotocol/server-github |
| Python packages | uvx |
uvx mcp-server-sqlite |
| Remote servers | HTTP | URL in config |
See opencode.json for a full example.
The container can be paired with a browser for frontend testing, visual verification, and DevTools-based workflows. Two approaches:
Run Chrome on your host machine with remote debugging enabled, then configure the MCP to connect through Docker's host gateway:
# On your host machine (macOS/Linux):
chrome --remote-debugging-port=9222 --no-sandbox
# Point the MCP at the host's Chrome from inside the container:
# MCP server URL: http://host.docker.internal:9222/jsonNo changes to the container — Chrome runs on the host. All DevTools tools (snapshot, click, fill, evaluate, performance, etc.) work over this connection.
For CI-style environments or when you don't want to depend on a host browser, add Playwright or Puppeteer to your setup — they bundle their own Chromium:
# In your Dockerfile or at runtime:
npx playwright install chromiumThis approach works out-of-the-box in the container but uses Playwright/Puppeteer APIs directly rather than the Chrome DevTools MCP protocol.
The docker-entrypoint.sh handles startup automatically:
- Config auto-detection — Looks for
/config/opencode.jsoncfirst, then/config/opencode.json. Override with theOPENCODE_CONFIGenvironment variable. - Directory linking — Symlinks
/config→~/.config/opencodeand/data→~/.local/share/opencodeso OpenCode finds them in their default locations. - Debug mode — Set
DEBUG=trueto print version info, PATH, config and symlink status on startup.
The container has a built-in HEALTHCHECK that pings the OpenCode server every 30s. Works with Docker's health status and orchestration tools.
MIT