Skip to main content

Global Options

These options work with all commands unless otherwise noted.

-h, —help

Display help information and exit.
boolean
default:"false"
Show help message with usage, commands, and examples
Short form: -h
Behavior:
  • Displays help text and exits
  • Overrides all other commands and options
  • Works from any directory

-d, —directory

Specify the working directory for the OpenCode instance.
string
default:"current directory"
Absolute or relative path to the project directory
Short form: -d
Default: Current working directory (process.cwd()) Behavior:
  • Path is resolved to absolute path
  • Used as the working directory for OpenCode server
  • Used to identify instances (one instance per directory)
  • Directory basename becomes default instance name
  • In Docker mode, directory is mounted into the container at the same path
Examples:

-p, —port

Specify the port for the Web UI server.
number
default:"3000"
Port number for the Web UI (1-65535)
Short form: -p
Default: 3000 (or next available port) Behavior:
  • If port is not specified, OpenPortal attempts to use port 3000
  • If port 3000 is in use, automatically finds the next available port
  • If port is explicitly specified but unavailable, OpenPortal will fail
  • Only applicable to default command (not run command)
  • Port is bound to the hostname specified by --hostname
Examples:
The run command does not start a Web UI, so the --port option is ignored for that command.

—opencode-port

Specify the port for the OpenCode server.
number
default:"4000"
Port number for the OpenCode API server (1-65535)
Default: 4000 (or next available port) Behavior:
  • If port is not specified, OpenPortal attempts to use port 4000
  • If port 4000 is in use, automatically finds the next available port
  • If port is explicitly specified but unavailable, OpenPortal will fail
  • Port is bound to the hostname specified by --hostname
  • In Docker mode, port is mapped from container to host
Examples:

—hostname

Specify the hostname or IP address to bind servers to.
string
default:"0.0.0.0"
Hostname or IP address for server binding
Default: 0.0.0.0 Common Values:
  • 0.0.0.0 - Bind to all network interfaces (accessible from network)
  • 127.0.0.1 - Bind to localhost only (local access only)
  • Specific IP - Bind to specific network interface
Behavior:
  • Both OpenCode server and Web UI bind to this hostname
  • In Docker mode, the container binds to 0.0.0.0 internally, but port mapping uses the specified hostname
  • Display URLs use localhost when hostname is 0.0.0.0
Security Considerations:
Using 0.0.0.0 makes your instance accessible from other machines on the network. Use 127.0.0.1 for local-only access.
Examples:

—name

Specify a custom name for the instance.
string
default:"directory basename"
Custom name to identify the instance
Default: Directory basename (e.g., my-project from /path/to/my-project) Behavior:
  • Used to identify instances in openportal list output
  • Used in Docker container names: openportal-{name}-{random-id}
  • Helpful when running multiple instances
  • Can be used with openportal stop --name to stop specific instance
Examples:

—docker

Run OpenCode in a Docker container instead of as a local process.
boolean
default:"false"
Enable Docker mode for OpenCode server
Default: false (process mode) Behavior:
  • OpenCode runs in a Docker container
  • Web UI still runs as a local process (default command only)
  • Working directory is mounted into container
  • Container uses image specified by OPENCODE_DOCKER_IMAGE environment variable
  • Container is created with AutoRemove: true for automatic cleanup
  • Validates mount path for security (prevents mounting system directories)
  • If image doesn’t exist locally, automatically pulls from registry
Requirements:
  • Docker daemon must be running
  • Docker socket accessible (/var/run/docker.sock on Unix, //./pipe/docker_engine on Windows)
  • Working directory must be an absolute path
  • Working directory cannot be a sensitive system directory
Docker Image: Default: ghcr.io/anomalyco/opencode:1.1.3 Customize with environment variable:
Examples:
Example Output:
Security Validations: OpenPortal blocks mounting of sensitive directories: Unix/Linux:
Windows:

Option Combinations

All Options Together

Common Patterns

Local development:
Custom ports:
Docker with custom name:
API server only:
Multiple instances:

Environment Variables

In addition to command-line options, OpenPortal supports environment variables:

OPENCODE_DOCKER_IMAGE

string
default:"ghcr.io/anomalyco/opencode:1.1.3"
Docker image to use when running in Docker mode

DOCKER_HOST

string
default:"platform-specific"
Docker daemon connection string
Supported formats:
  • unix:///var/run/docker.sock - Unix socket
  • tcp://localhost:2375 - TCP connection
  • npipe:////./pipe/docker_engine - Windows named pipe
Default values:
  • Unix/Linux/macOS: /var/run/docker.sock
  • Windows: //./pipe/docker_engine

DEBUG

boolean
default:"false"
Enable debug logging for Docker operations
Enables debug output for Docker operations like container checks and cleanup.

Option Parsing Rules

Long Options

Short Options

Boolean Flags

Multiple Options

Directory as Argument


Command-Specific Option Availability

Default Command

Supports all options:
  • -h, --help
  • -d, --directory
  • -p, --port
  • --opencode-port
  • --hostname
  • --name
  • --docker

run Command

Supports:
  • -h, --help
  • -d, --directory
  • --opencode-port (not --port)
  • --hostname
  • --name
  • --docker

stop Command

Supports:
  • -h, --help
  • -d, --directory
  • --name

list / ls Command

Supports:
  • -h, --help

clean Command

Supports:
  • -h, --help

Examples by Use Case

Development Setup

Docker Development

API Integration

Multiple Projects

Network Access