A Docker container with the OpenCode CLI pre-installed and ready to use.
This project mirrors the approach used in claude-container and devstral-container: run the CLI in an isolated environment with a persisted config directory and your local workspace mounted in /workspace.
# Download and install
curl -o ~/.local/bin/opencode-container https://raw.githubusercontent.com/nezhar/opencode-container/main/bin/opencode-container
chmod +x ~/.local/bin/opencode-container
# Run OpenCode
opencode-containerMake sure ~/.local/bin is in your PATH, or install system-wide with sudo:
sudo curl -o /usr/local/bin/opencode-container https://raw.githubusercontent.com/nezhar/opencode-container/main/bin/opencode-container
sudo chmod +x /usr/local/bin/opencode-containerdocker run --rm -it \
-v "$(pwd):/workspace" \
-v "$HOME/.config/opencode-container:/config" \
-v "$HOME/.local/share/opencode:/data" \
-e "HOME=/config" \
-e "OPENCODE_CONFIG_DIR=/config" \
-e "XDG_DATA_HOME=/data" \
nezhar/opencode-cli:latestopencode-container --help
opencode-container --pull
opencode-container --shell
opencode-container "analyze the code"
opencode-container --proxy --proxy-provider openai --proxy-target https://api.openai.com
opencode-container --datasette --proxy-provider openai --proxy-target https://api.openai.com
opencode-container --proxy-allEnable API logging through a reverse proxy and store requests/responses in SQLite:
opencode-container --proxy \
--proxy-provider openai \
--proxy-target https://api.openai.comLogs are stored at:
~/.config/opencode-container/proxy/logs.db
To explore logs in a web UI, start Datasette:
opencode-container --datasette \
--proxy-provider openai \
--proxy-target https://api.openai.comDatasette is available at http://localhost:8001.
No other host ports are published by default.
If your provider uses a different base path, override the base URL injected into OpenCode:
opencode-container --proxy \
--proxy-provider openai \
--proxy-target https://api.openai.com \
--proxy-base-url http://opencode-proxy:8080/v1To capture requests from multiple providers without changing OpenCode config:
opencode-container --proxy-allThis sets HTTP_PROXY/HTTPS_PROXY for the CLI container and trusts the mitmproxy CA.
If HTTPS requests fail on first run, re-run the command after the proxy generates its
CA files in ~/.config/opencode-container/proxy/certs.
Configuration is stored on the host in:
~/.config/opencode-container
Credentials are stored on the host in:
~/.local/share/opencode/auth.json
These paths are mounted into the container as /config and /data, with HOME=/config and XDG_DATA_HOME=/data.
Proxy-related environment variables:
OPENCODE_PROXY_PROVIDER
OPENCODE_PROXY_TARGET
OPENCODE_PROXY_BASE_URL
OPENCODE_PROXY_DATA
OPENCODE_PROXY_MODE
OPENCODE_PROXY_PORT
OPENCODE_DATASETTE_PORT
OPENCODE_PROXY_IMAGE
OPENCODE_DATASETTE_IMAGE
docker compose buildmkdir -p ~/.local/share/bash-completion/completions
cp completions/opencode-container ~/.local/share/bash-completion/completions/claude-containerdevstral-container