Skip to main content
OpenCode Portal supports running OpenCode in Docker containers, providing isolation and easier deployment management.

Overview

OpenPortal can run OpenCode in a Docker container while keeping the web UI as a host process. This provides:
  • Isolated OpenCode environment
  • Consistent runtime across different systems
  • Easy cleanup and management
  • No need to install OpenCode locally

Prerequisites

1

Install Docker

Ensure Docker is installed and running on your system.
Verify Docker installation:
2

Install Bun

OpenPortal requires Bun to run the web UI:
3

Install OpenPortal

Install OpenPortal globally:
You do NOT need to install OpenCode when using Docker mode - the container includes it.

Running with Docker

Start OpenCode + Web UI in Docker Mode

Use the --docker flag to run OpenCode in a container:
This will:
  1. Pull the OpenCode Docker image (if not already available)
  2. Create and start a container with your project directory mounted
  3. Start the web UI on the host

Start Only OpenCode Server in Docker

This starts only the OpenCode server in a Docker container without the web UI.

Docker Configuration

Default Docker Image

By default, OpenPortal uses:

Custom Docker Image

You can specify a custom OpenCode Docker image using the OPENCODE_DOCKER_IMAGE environment variable:
Or export it for persistent use:

Remote Docker Host

To connect to a remote Docker daemon, use the DOCKER_HOST environment variable:

CLI Options with Docker

All standard OpenPortal options work with Docker mode:

Custom Ports

Custom Directory

Custom Instance Name

Hostname Binding

Managing Docker Instances

List Running Instances

Output includes Docker container information:

Stop Docker Instances

This will:
  1. Stop the Docker container
  2. Remove the container (auto-cleanup)
  3. Stop the web UI process

Clean Up Stale Entries

Removes stopped containers and cleans up configuration entries.

Volume Mounts

OpenPortal automatically mounts your project directory into the container:
The container’s working directory is set to your project path, so OpenCode operates on your files directly.
For security, OpenPortal prevents mounting sensitive system directories like /, /etc, /usr, etc.

Port Mapping

The OpenCode server port is exposed from the container:
The web UI runs on the host and connects to the containerized OpenCode server via the exposed port.

Container Lifecycle

Container Naming

Containers are automatically named:
Example: openportal-my-project-a1b2c3d4

Auto-Removal

Containers are created with the AutoRemove flag, meaning they’re automatically removed when stopped.

Container Logs

View container logs directly:

Advanced Docker Usage

Multiple Projects

Run multiple projects simultaneously:

Server-Only Mode with Docker

Run only the OpenCode server in Docker:
This is useful when:
  • You want to use a different UI
  • You’re integrating with external tools
  • You only need the OpenCode API

Inspecting Containers

Environment Variables

OPENCODE_DOCKER_IMAGE

Specify the OpenCode Docker image to use:

DOCKER_HOST

Specify the Docker daemon connection:

DEBUG

Enable debug output for troubleshooting:

Troubleshooting

Docker Image Pull Issues

If the image fails to pull:

Container Won’t Start

Check container logs:

Port Already in Use

Specify different ports:

Volume Mount Errors

Ensure the path is absolute:

Permission Issues

On Linux, ensure your user is in the docker group:

Container Not Stopping

Manually stop and remove:

Connection Refused

Verify the container is running and port is exposed:

Benefits of Docker Mode

Isolation

  • OpenCode runs in an isolated environment
  • No interference with host system packages
  • Clean separation of concerns

Consistency

  • Same OpenCode version across all environments
  • Reproducible builds and deployments
  • Easy version management via image tags

Easy Cleanup

  • Containers auto-remove when stopped
  • No residual files on host system
  • Simple instance management

No Local Installation

  • No need to install OpenCode on host
  • No dependency conflicts
  • Works on any system with Docker

Next Steps