1<!doctype html><html lang=en class=no-js><head>
1<script>document.documentElement.classList.replace("no-js","js")</script>
1<meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>opencode + qwen3-coder-30b on ollama + opencode on my 3090</title><link rel=icon type=image/png href=/img/khayyam.png><link rel=preconnect href=https://fonts.googleapis.com><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel=stylesheet><link rel=stylesheet href=/css/custom.d1646893b2939af7864fcd2d39150d1e826fea4d366135fd0d71353fadb76ce0.css></head><body><header class=site-header><h1><a href=/>k5m.sh</a></h1></header><main><article><header><h1>opencode + qwen3-coder-30b on ollama + opencode on my 3090</h1><p class=post-meta>21 May 2026 · updated 22 May 2026</p></header><nav class=toc id=toc><details open><summary class=toc-title>contents</summary><nav id=TableOfContents><ul><li><a href=#what-is-opencode>What is opencode?</a></li><li><a href=#the-setup>The Setup</a><ul><li><a href=#environment>Environment</a></li><li><a href=#integration-with-existing-docker-setup>Integration with existing Docker setup</a></li></ul></li><li><a href=#key-configuration-elements>Key Configuration Elements</a><ul><li><a href=#docker-socket-access>Docker Socket Access</a></li><li><a href=#persistent-storage>Persistent Storage</a></li></ul></li><li><a href=#leveraging-qwen3-coder-30b-on-ollama>Leveraging Qwen3-Coder-30B on Ollama</a></li><li><a href=#using-opencode-with-docker-composeaiyml>Using opencode with docker-compose.ai.yml</a></li><li><a href=#why-this-setup-works>Why This Setup Works</a></li><li><a href=#benefits>Benefits</a></li><li><a href=#opencode-integration>OpenCode Integration</a></li></ul></nav></details></nav><p>I’ve been exploring the <a href=https://opencode.ai>opencode</a> AI assistant system as part of my ongoing AI infrastructure setup. After setting it up, I wanted to document how I integrated it into my existing Docker-based environment.</p><h2 id=what-is-opencode>What is opencode?<a class=heading-anchor href=#what-is-opencode>#</a></h2><p><a href=https://opencode.ai>opencode</a> is an open-source, self-hosted AI assistant that aims to provide a more secure and flexible alternative to cloud-based solutions. It allows for local execution of AI models while providing a rich interface for task automation and code execution.</p><h2 id=the-setup>The Setup<a class=heading-anchor href=#the-setup>#</a></h2><h3 id=environment>Environment<a class=heading-anchor href=#environment>#</a></h3><p>My base environment:</p><ul><li><strong>Host system</strong>: Linux with Docker Engine</li><li><strong>Hardware</strong>: NVIDIA GPU (GTX 1080 Ti, 11GB VRAM) and RTX 3090 (24GB VRAM)</li><li><strong>Infrastructure</strong>: Multiple Docker Compose stacks managed by a top-level compose file</li><li><strong>AI ecosystem</strong>: Ollama for local LLM inference</li></ul><h3 id=integration-with-existing-docker-setup>Integration with existing Docker setup<a class=heading-anchor href=#integration-with-existing-docker-setup>#</a></h3><p>I integrated opencode into my existing Docker Compose setup by adding it to the docker-compose.ai.yml file that manages AI-related services. The configuration includes:</p><ol><li><p><strong>Docker Build Context</strong>: The service is built from the <code>./opencode</code> directory</p></li><li><p><strong>Volume Mounts</strong>:</p><ul><li>Mounts config.json for opencode configuration</li><li>Mounts the workspace directory (<code>/home/khayyam</code>) for file access</li><li>Mounts Docker socket (<code>/var/run/docker.sock</code>) for container management capabilities</li><li>Persists opencode data to a named volume for persistence</li></ul></li><li><p><strong>Environment Variables</strong>:</p><ul><li>Sets server password from environment variable</li><li>Points OLLAMA_BASE_URL to the local gateway service</li><li>Inherits GitHub tokens from environment variables</li></ul></li><li><p><strong>Network and Port Configuration</strong>:</p><ul><li>Exposes port 4096 locally</li><li>Depends on ollama-gateway service for LLM inference</li></ul></li><li><p><strong>Resource Constraints</strong>:</p><ul><li>CPU and memory limits as per other services</li><li>Health checks for monitoring</li></ul></li></ol><h2 id=key-configuration-elements>Key Configuration Elements<a class=heading-anchor href=#key-configuration-elements>#</a></h2><h3 id=docker-socket-access>Docker Socket Access<a class=heading-anchor href=#docker-socket-access>#</a></h3><p>One of the most important aspects of opencode’s setup is its need for Docker socket access to orchestrate containers. This is essential for its code execution and automation features:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none><code class=language-yaml data-lang=yaml><span style=display:flex><span><span style=color:#f92672>volumes</span>: 2</span></span><span style=display:flex><span> - <span style=color:#ae81ff>/var/run/docker.sock:/var/run/docker.sock:ro</span> 3</span></span></code></pre></div><h3 id=persistent-storage>Persistent Storage<a class=heading-anchor href=#persistent-storage>#</a></h3><p>For maintaining configuration and state information across restarts, I used a persisted volume:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none><code class=language-yaml data-lang=yaml><span style=display:flex><span><span style=color:#f92672>volumes</span>: 4</span></span><span style=display:flex><span> - <span style=color:#ae81ff>opencode-data:/root/.local/share/opencode</span> 5</span></span></code></pre></div><h2 id=leveraging-qwen3-coder-30b-on-ollama>Leveraging Qwen3-Coder-30B on Ollama<a class=heading-anchor href=#leveraging-qwen3-coder-30b-on-ollama>#</a></h2><p>My specific setup includes using the Qwen3-Coder-30B model with Ollama, running on a high-end RTX 3090 GPU. The key integration points include:</p><ol><li><strong>Model Serving</strong>: The Ollama service that hosts Qwen3-Coder-30B is configured to run on the 3090 GPU</li><li><strong>Resource Allocation</strong>: The model service is allocated sufficient GPU memory and CPU resources</li><li><strong>Integration with opencode</strong>: opencode uses the same OLLAMA_BASE_URL to access the Qwen3-Coder-30B model</li></ol><p>This allows opencode to leverage the powerful code generation capabilities of Qwen3-Coder-30B for tasks requiring sophisticated code understanding and generation.</p><h2 id=using-opencode-with-docker-composeaiyml>Using opencode with docker-compose.ai.yml<a class=heading-anchor href=#using-opencode-with-docker-composeaiyml>#</a></h2><p>
5A key aspect of integrating opencode into my infrastructure is how it connects with my existing Docker Compose setup. I’ve configured opencode to run alongside other AI services in a dedicated <code>docker-compose.ai.yml</code> file:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none><code class=language-yaml data-lang=yaml><span style=display:flex><span><span style=color:#f92672>services</span>: 6</span></span><span style=display:flex><span> <span style=color:#f92672>opencode</span>: 7</span></span><span style=display:flex><span> <span style=color:#f92672>build</span>: <span style=color:#ae81ff>./opencode</span> 8</span></span><span style=display:flex><span> <span style=color:#f92672>volumes</span>: 9</span></span><span style=display:flex><span> - <span style=color:#ae81ff>./opencode/config.json:/root/.config/opencode/config.json</span> 10</span></span><span style=display:flex><span> - <span style=color:#ae81ff>/home/khayyam:/workspace</span> 11</span></span><span style=display:flex><span> - <span style=color:#ae81ff>/var/run/docker.sock:/var/run/docker.sock:ro</span> 12</span></span><span style=display:flex><span> - <span style=color:#ae81ff>opencode-data:/root/.local/share/opencode</span> 13</span></span><span style=display:flex><span> <span style=color:#f92672>environment</span>: 14</span></span><span style=display:flex><span> - <span style=color:#ae81ff>OPENCODE_PASSWORD=${OPENCODE_PASSWORD}</span> 15</span></span><span style=display:flex><span> - <span style=color:#ae81ff>OLLAMA_BASE_URL=http://ollama-gateway:11434</span> 16</span></span><span style=display:flex><span> - <span style=color:#ae81ff>GITHUB_TOKEN=${GITHUB_TOKEN}</span> 17</span></span><span style=display:flex><span> <span style=color:#f92672>ports</span>: 18</span></span><span style=display:flex><span> - <span style=color:#e6db74>"4096:4096"</span> 19</span></span><span style=display:flex><span> <span style=color:#f92672>depends_on</span>: 20</span></span><span style=display:flex><span> - <span style=color:#ae81ff>ollama-gateway</span> 21</span></span><span style=display:flex><span> <span style=color:#75715e># ... additional configuration</span> 22</span></span></code></pre></div><p>This configuration allows opencode to:</p><ul><li>Access the same OLLAMA_BASE_URL for inference, enabling it to use models like Qwen3-Coder-30B</li><li>Access Docker socket for container orchestration capabilities</li><li>Utilize the workspace directory for file operations</li><li>Maintain persistent storage for configuration and state</li></ul><p>This setup ensures that opencode works seamlessly alongside other AI infrastructure components in a unified Docker-based environment.</p><p><figure><img src=/images/opencode/logo.png alt="OpenCode Logo" loading=lazy><figcaption>OpenCode Logo</figcaption></figure></p><p>The Qwen project is an open-source large language model developed by Alibaba Cloud, with the Qwen3-Coder series specifically designed for code understanding and generation tasks. This integration demonstrates how opencode can work with cutting-edge open-source models to provide powerful AI capabilities locally.</p><h2 id=why-this-setup-works>Why This Setup Works<a class=heading-anchor href=#why-this-setup-works>#</a></h2><p>The integration works well with my existing infrastructure because:</p><ul><li>It leverages the same Ollama services I was already using via the ollama-gateway</li><li>It shares the same Docker network and resource constraints</li><li>It integrates seamlessly with my existing monitoring and backup routines</li><li>The container-based approach allows for easy updates and version management</li></ul><h2 id=benefits>Benefits<a class=heading-anchor href=#benefits>#</a></h2><ol><li><strong>Security</strong>: All operations happen locally with no data leaving the system</li><li><strong>Customizability</strong>: Full control over configuration and behavior</li><li><strong>Integration</strong>: Works well with existing Docker tools</li><li><strong>Cost-effective</strong>: No ongoing API fees beyond hardware</li><li><strong>Extensible</strong>: Can easily add new tools and capabilities</li></ol><p>This setup demonstrates how opencode can be integrated into an existing sophisticated Docker-based infrastru
22cture, providing a powerful, secure AI assistant solution that leverages high-end local models for code generation tasks.</p><h2 id=opencode-integration>OpenCode Integration<a class=heading-anchor href=#opencode-integration>#</a></h2><p>This setup shows the power of OpenCode’s integration capabilities with local AI infrastructure. OpenCode’s architecture allows it to:</p><ul><li>Seamlessly connect to local Ollama instances for inference</li><li>Leverage Docker containers for orchestration and automation</li><li>Access workspace directories for file manipulation</li><li>Utilize Docker socket access for container management</li><li>Persist configuration and state information</li></ul><p><figure><img src=/images/opencode/logo.png alt="OpenCode Logo" loading=lazy><figcaption>OpenCode Logo</figcaption></figure></p><p>OpenCode’s modular design and containerized approach make it a perfect fit for sophisticated AI infrastructure that requires both local execution security and powerful automation capabilities.</p></article><div class=post-badges><div class=post-badge data-tooltip=khayyam><img class=author-avatar src=/img/khayyam.png alt=khayyam></div></div></main><footer class=site-footer><p>© 2026 · Built with <a href=https://gohugo.io/>Hugo</a></p><p class=socials><a href=https://github.com/khayyamsaleem rel=me>GitHub</a> · 23<a href=mailto:[email protected] rel=me>Email</a> · 24<a href=https://www.linkedin.com/in/khayyamsaleem rel=me>LinkedIn</a> · 25<a href=https://bsky.app/profile/ok97.bsky.social rel=me>Bluesky</a> · 26<a href=https://twitter.com/khayyamsaleem rel=me>Twitter</a> · 27<a href=https://hachyderm.io/@khayyam rel=me>Mastodon</a></p></footer>
27<script src=/js/theme-toggle.c3208a3d88267563d6c1020f0d08f654704865becb3c77dd39902fc42b10549a.js></script>
27<script src=https://cdn.jsdelivr.net/npm/@twemoji/api@latest/dist/twemoji.min.js crossorigin=anonymous></script>
27<script>twemoji.parse(document.body,{folder:"svg",ext:".svg"})</script>
27<script src=/js/ansi.b8356cbfade97c8410a1ccf5d4259b7ed36d94cc7c896f1624f139725208957e.js defer></script>
27<script src=/js/toc.3de390f3ef51aaaa6948a0a734a1afb412aa8faf4969f793a962c4d593871527.js defer></script>
27<script src=/js/lightbox.81ee9917c898dad80e42ee671d2938f9af2dd0d18888e4e669a6b2a9e0bccd8d.js defer></script>
27<script src=/js/maps-preview.3b1cf9b6b9ec8070c7db763fd8263843591ae27f0b32be61a4554e0c067c50c5.js defer></script>
27</body></html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.