This is to fix the problem with docker creating those directories to mount it inside of the container-home. This only happens when the project path is inside of $HOME which is mounted to the .local/share/opencode-container/cantainer-home With it like this, the empty directories are owned by the local user and not root and it's easier to clean up in the future. |
||
|---|---|---|
| .gitignore | ||
| Dockerfile | ||
| force-cleanup.sh | ||
| opencode-container.py | ||
| opencode.aliases | ||
| README.md | ||
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 Linux–based 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 XDG_DATA_HOME/opencode-container/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 XDG_DATA_HOME/opencode-container/container-home directory as a central $HOME inside of the container, independent of the session or project directory we start in. This persists the whole $HOME from inside the container so everything OpenCode writes into config files, etc. persists there.
Environment Variables
XDG_DATA_HOME: Override default data directory (default: ~/.local/share)
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.