Debian-based image with OpenCode CLI
preinstalled, plus common editor and search tools (git, ripgrep,
fd, vim, nano, etc.).
The default container user is user (override at build time with
CONTAINER_USER). Working directory is /workspaces.
From this directory:
docker build -t opencode .From the repository root:
docker build -t opencode -f opencode/Dockerfile opencode| Argument | Default | Description |
|---|---|---|
CONTAINER_USER |
user |
Non-root user created in the image |
ENVIRONMENT |
production |
production or development (adds doas/sudo tooling) |
NANO_CLASSIC_KEYBINDINGS |
(unset) | Set to yes for classic nano keybindings |
OPENCODE_VERSION |
1.18.21 |
OpenCode version to install |
Examples:
docker build -t opencode:dev --build-arg ENVIRONMENT=development .
docker build -t opencode:1.18.21 --build-arg OPENCODE_VERSION=1.18.21 .The installer is invoked with --no-modify-path; the binary is copied
to /usr/local/bin/opencode. The builder does not strip the
executable, so the Bun-compiled payload at the tail of the binary is
preserved.
See the root README for development-image privilege setup.
docker run --rm -it \
-v "$PWD:/workspaces/project" \
-w /workspaces/project \
opencode opencodeAuthenticate according to OpenCode’s documentation for your environment.
| Path | Description |
|---|---|
/usr/local/bin/opencode |
OpenCode CLI binary |
/workspaces |
Default working directory |
The image only copies the binary into /usr/local/bin. Runtime config
and sessions may still be written under the container user’s home (for
example ~/.opencode or paths documented by your version). Mount those
paths if you need state across runs:
docker run --rm -it \
-v "$HOME/.opencode:/home/user/.opencode" \
-v "$PWD:/workspaces/project" \
-w /workspaces/project \
opencode opencodeNotice: If you mount a host directory that is meant to hold a full
OpenCode install tree over a path that also contains install assets in
some setups, ensure the host tree is complete--or keep the image binary
in /usr/local/bin and only mount mutable config/session data.
The monorepo root Dockerfile can also include OpenCode via multi-stage
targets. This directory is a standalone build so you can image
OpenCode without the multi-agent graph.