This repository provides a Docker image for running OpenCode. The image is automatically built and updated via GitHub Actions whenever a new release of OpenCode is published.
Published images are available on GitHub Container Registry at ghcr.io/pilinux/opencode,
tagged with the corresponding OpenCode version (e.g., ghcr.io/pilinux/opencode:1.2.5) and latest.
List of available versions can be found on the GitHub Container Registry page.
- Docker
- Docker Compose
You can run the OpenCode server using the provided docker-compose.yml:
docker compose up -dThis will start the OpenCode web interface on http://localhost:4096.
TZ- Timezone settingPUID- User ID the OpenCode server runs as (default:1000)PGID- Group ID the OpenCode server runs as (default:1000)OPENCODE_SERVER_USERNAME- Server usernameOPENCODE_SERVER_PASSWORD- Server password
The container starts as root, remaps the internal opencode user to PUID/PGID,
fixes the ownership of the mounted data directories if needed, and then drops privileges
before starting OpenCode. This keeps bind-mounted host directories (e.g. ./data) writable
regardless of which user owns them on the host.
Set PUID/PGID in .env (see .env.sample) to the IDs of the host user that should own the data.
You can look them up with:
id -u # PUID
id -g # PGIDNotes:
PUID/PGIDmust be numeric and must not be0; OpenCode is never run as root.- Ownership is only changed when something differs, so restarts stay fast.
- Images before this change ran as UID/GID
1001. On the first start with the defaultPUID/PGID, existing files in./dataare re-owned to1000:1000. SetPUID=1001andPGID=1001to keep the previous ownership. - For hardened setups (
read_only: true,cap_drop: [ALL]) the root remapping step cannot run. Useuser: "<uid>:<gid>"instead ofPUID/PGID, and make sure the mounted directories are already owned by that user.
For persistent data and configuration, the following volumes can be mounted:
./data/share:/home/opencode/.local/share/opencode- For shared data, includingauth.jsonfor LLM provider pre-configuration./data/state:/home/opencode/.local/state/opencode./data/config:/home/opencode/.config/opencode- For configuration files, includingopencode.jsonfor OpenCode pre-configuration
To authenticate with LLM providers, you can create an auth.json file in the /home/opencode/.local/share/opencode directory with the following structure:
{
"github-copilot": {
"type": "oauth",
"access": "",
"refresh": "",
"expires": 0
}
}opencode.json can be used and saved to the /home/opencode/.config/opencode directory to pre-configure LLM providers.
For example, to whitelist specific models for the GitHub Copilot provider, you can use the following configuration:
{
"$schema": "https://opencode.ai/config.json",
"model": "github-copilot/gpt-5-mini",
"provider": {
"github-copilot": {
"whitelist": ["gpt-5-mini", "gpt-4.1"]
}
}
}The Docker image is built for both linux/amd64 and linux/arm64 architectures.
Images are automatically pushed to GitHub Container Registry (ghcr.io/pilinux/opencode) with version tags matching OpenCode releases and a latest tag for the most recent release.
Feel free to open issues or submit pull requests for improvements to the Docker setup.
Released under the MIT license.
This repository is not affiliated with the OpenCode project. It is an independent effort to provide a Docker image for OpenCode users. The OpenCode project is developed and maintained by the Anomaly team. For any issues or contributions related to OpenCode itself, please refer to the OpenCode repository.