r/opencodeCLI • u/ExternalStaff • 1h ago
Best Practice / Guide for setting up OpenCode in a Docker container or sandbox?
My Ideal setup would be something like - OpenCode using VSCode with Git, node, python, C++ and Rust all installed and ready to use, plus my skills, scripts and MCP's. All in one docker sandbox, setup remains consistent every time I launch.
Can I use the GUi with a docker sandbox?
Is there a guide for this? What would you do differently?
4
Upvotes
1
u/4SubZero20 1h ago
I do this. I didn't follow any guide or best practices on the Internet.
I just read about people on the Internet complaining that their Agent deleted important directories and sometimes even root. I knew I didn't want that; and that was the motivation I needed to run my agents/work in Docker.
Now I also believe in first trying the tools you have/know, before reaching for something new.
This lead me to just create a normal Dockerfile and install everything I want/need in my "development environment" (git, node, opencode, openchamber, Claude, github cli, etc.). I even call my image "dev-env".
Then I have a bash method (that starts a docker image/container) saved in my (host) .bashrc that I can call when in terminal and it drops me in a running container.
I have a secondary method in my .bashrc that attaches to the same container, so that I can additional in the container if/when needed and I'm not confined to 1 terminal.
Then in my containers' .bashrc, I have methods to start the OpenCode (V2) server, along with Openchamber and a few aliases so I can type
ocinstead ofopencode --server http://127.0.0.1:4098Note: In these steps, there is no GUI. This is a terminal first workflow on Linux (will probably work on Mac as well)