Docker image for running [OpenCode](https://opencode.ai) as a headless HTTP server.
## What is OpenCode?
OpenCode is an open source AI coding agent available as a terminal interface, desktop app, or IDE extension. This image runs it in server mode (`opencode serve`), exposing an HTTP API that clients can connect to.
## Pull
```bash
docker pull jcabillot/opencode
```
The image is rebuilt and pushed to Docker Hub automatically every night via the Jenkins pipeline.
## Build locally
```bash
docker build -t opencode .
```
## Run
```bash
docker run -it -p 4096:4096 jcabillot/opencode
```
By default the server listens on `127.0.0.1:4096`. To expose it on all interfaces:
```bash
docker run -it -p 4096:4096 jcabillot/opencode --hostname 0.0.0.0
```
### Mount a project
```bash
docker run -it -p 4096:4096 \
-v $(pwd):/home/opencode/project \
jcabillot/opencode --hostname 0.0.0.0
```
### Secure with a password
```bash
docker run -it -p 4096:4096 \
-e OPENCODE_SERVER_PASSWORD=your-password \
jcabillot/opencode --hostname 0.0.0.0
```
Authentication uses HTTP basic auth. The default username is `opencode`, override it with `OPENCODE_SERVER_USERNAME`.
## Troubleshooting helper
The image includes an `opencode-attach` wrapper in `PATH` that runs: