Run OpenCode inside an Arch Linux Docker container that closely mirrors a local development environment, while limiting access to sensitive files on the host.
Find a file
Jeena fc2e5b1bca Replace docker compose with persistent per-project lifecycle
Move from docker compose run to a Python-managed container lifecycle.
Each project now gets a dedicated container that is started on demand
and stopped when opencode exits, instead of being recreated each time.

Use a shared home directory across projects so configurations presist.

The container are not destroyed, so tools and caches can be installed
specifically for a project by opencode itself once and reused, while
still avoiding long-running containers.
2026-01-21 21:33:30 +09:00
container-home Fix problem where container home was seperate for each project dir 2026-01-15 12:19:07 +09:00
.gitignore Fix problem where container home was seperate for each project dir 2026-01-15 12:19:07 +09:00
Dockerfile Replace docker compose with persistent per-project lifecycle 2026-01-21 21:33:30 +09:00
opencode-container.py Replace docker compose with persistent per-project lifecycle 2026-01-21 21:33:30 +09:00
opencode.aliases Replace docker compose with persistent per-project lifecycle 2026-01-21 21:33:30 +09:00
README.md Fix README data -> container-home 2026-01-15 12:20:26 +09:00

opencode-container

Run OpenCode inside an Arch Linux Docker container that closely mirrors a local development environment, while limiting access to sensitive files on the host.

Features

  • Arch Linuxbased image
  • Runs as the host user (same username, UID, GID)
  • Mounts only the current project directory (same absolute path inside container)
  • Persists OpenCode state in ./container-home directory
  • No access to SSH keys, passwords, or full $HOME
  • Simple shell function (opencode) to launch interactively

Install

Change to your projects directory and clone the repository:

cd ~/Projects/
git clone https://git.jeena.net/jeena/opencode-container.git

Source the helper file opencode.aliases in your shell configuration
(.bashrc or .zshrc) so the opencode function is available in new sessions.

We set up the ./container-home directory as a central $HOME inside of the container, independent of the session or project directory we start in. This presists the whole $HOME from inside the container so everything opencode writes into config files, etc. presists there.

Usage

From any project directory:

opencode

The image is built automatically on first use if it does not already exist.
OpenCode starts inside the container with the current directory mounted and set as the working directory.