Skip to main content
This example installs OpenCode in a microVM and opens its terminal UI in an isolated workspace. Project files are copied into the sandbox rather than bind-mounted, so commands and edits cannot directly change the host checkout.

Run OpenCode

1

Start OpenCode

Replace ./my-project with the project directory you want OpenCode to work on:
The first run downloads the package and may take a couple of minutes. OpenCode should render its prompt and offer /connect for provider setup. The two named volumes retain its normal XDG configuration and data directories if you recreate the sandbox.
To try the TUI without a project, replace --copy-dir ./my-project:/workspace with --mkdir /workspace.
2

Start another session

After leaving OpenCode, return to the same sandbox and workspace with:
3

Verify the installation

Exit the TUI, then run:
The pinned example prints 1.18.4.
4

Export changes

Review the diff inside the sandbox before copying anything back:
For a Git repository, export a patch instead of replacing your host checkout:
Copy the patch to the host:
Check that it applies cleanly before applying it:
5

Clean up

Remove the sandbox:
Remove persisted configuration and data only when you no longer need them:
Keep the volumes if you want to retain provider connections, sessions, and OpenCode configuration. Never copy an agent’s entire home directory back to the host.

Reference