Why Use the Container?
Isolated Environment
Run OpenCode in a container without affecting your local system. Perfect for CI/CD and testing.
Pre-configured
Comes with Bun runtime, Git, and Station plugin pre-installed.
OAuth Support
Use Claude Max subscription via OAuth instead of API keys.
NATS Integration
Built-in Station plugin for NATS-based task dispatch.
Quick Start with Station CLI
The easiest way to run OpenCode in a container is using the Station CLI. This manages Docker Compose for you and uses your existing Anthropic OAuth credentials.1
Start the Sandbox
2
Configure Station
3
Run Your Agent
Management Commands
Custom Port
With NATS (CloudShip Orchestration)
The Station CLI method uses
ghcr.io/cloudshipai/opencode-station:latest which includes the Station NATS plugin pre-installed.Manual Docker Setup
If you prefer manual Docker control, use the steps below.1. Pull the Image
2. Run with API Key
3. Test the Connection
Authentication Options
Option 1: API Keys
Pass API keys as environment variables:Option 2: OAuth (Claude Max)
For Claude Max subscribers, use OAuth authentication instead of API keys:1
Login on Host
Run
opencode auth login on your host machine to generate OAuth credentials:2
Mount Credentials
Mount only the
auth.json file (read-only) into the container:Docker Compose
Basic Setup
With OAuth (Claude Max)
Full Stack with NATS
For Station integration with NATS-based task dispatch:Configuration
OpenCode Config File
Create a customopencode.json for the container:
Available Models
Environment Variables
Building Custom Image
For Station integration with the NATS plugin:Dockerfile
Entrypoint Script
Build and Run
Using with Station
Station can connect to the OpenCode container via two backends:Option 1: HTTP Backend (Direct)
Station calls OpenCode’s HTTP API directly. Simple setup, good for local development.Option 2: NATS Backend (Plugin-based)
Station publishes tasks to NATS, the Station plugin in the container receives them and executes via OpenCode. Better for distributed setups.- With Station's Embedded NATS (Recommended)
- With Standalone NATS
Station includes an embedded NATS server that starts automatically. No separate NATS installation needed.How it works:Verify connectivity:Embedded NATS environment variables (on Station host):
- Station starts embedded NATS on port 4222
- OpenCode container connects via
host.docker.internal - Tasks flow: Station → NATS → Station Plugin → OpenCode
The
extra_hosts configuration is only needed on Linux. macOS and Windows Docker Desktop include host.docker.internal by default.See Configuration for full details.
Create a Coding Agent
The agent definition is the same regardless of backend - just enable coding:Notice the agent doesn’t specify
backend: opencode or backend: opencode-nats. The backend is determined by Station’s config, making agents portable across different deployments.Run the Agent
Testing
Health Check
Create Session
Send Message
Troubleshooting
OAuth Token Not Working
Verify token is mounted correctly
Verify token is mounted correctly
Token expired
Token expired
Re-run
opencode auth login on your host to refresh the token, then restart the container.Read-Only Filesystem Error
If you seeEROFS: read-only file system errors:
~/.local/share/opencode directory as read-only.
Fix: Mount only auth.json:
Empty Response from API
If API calls return200 OK but with empty body:
- Check container logs:
docker logs <container> - Verify model is configured in
opencode.json - Ensure API key or OAuth credentials are valid
Container Can’t Reach NATS
Next Steps
OpenCode Backend
Configure Station to use OpenCode
Docker Deployment
Deploy Station with Docker
Sandbox Execution
Run code in isolated containers
Workflows
Multi-step agent orchestration

