---
title: "OpenCode with Docker Model Runner for Private AI Coding"
description: "OpenCode can use locally hosted models by pointing an @ai-sdk/openai-compatible provider in opencode.json at Docker Model Runner's OpenAI-compatible endpoint (localhost:12434/v1, with TCP enabled on Docker Desktop)."
url: "https://swe.quest/articles/opencode-with-docker-model-runner-for-private-ai-coding-640e2f146435d737"
canonical: "https://www.docker.com/blog/opencode-docker-model-runner-private-ai-coding/"
source: "Docker"
published: "2026-01-15"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["ai-coding","inference","llms","containers"]
---

# OpenCode with Docker Model Runner for Private AI Coding

A post on [Docker](https://swe.quest/sources/docker.md), published 2026-01-15, 8 min read, How-to. Original: [https://www.docker.com/blog/opencode-docker-model-runner-private-ai-coding/](https://www.docker.com/blog/opencode-docker-model-runner-private-ai-coding/)

## Summary

OpenCode can use locally hosted models by pointing an @ai-sdk/openai-compatible provider in opencode.json at Docker Model Runner's OpenAI-compatible endpoint (localhost:12434/v1, with TCP enabled on Docker Desktop). Prompts and code then stay on infrastructure you control, and there are no per-token costs. Coding models such as qwen3-coder and devstral-small-2 ship with 128K context, while gpt-oss defaults to 4,096 tokens. \`docker model package --context-size\` can repackage gpt-oss as a 128K OCI artifact that teams push to a registry to standardize and version model variants.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI for coding](https://swe.quest/tags/ai-coding.md) (AI & ML)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Containers](https://swe.quest/tags/containers.md) (Infrastructure)

## Prerequisites

- Docker CLI basics ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))
- OpenAI-compatible APIs ([easy posts on API design](https://swe.quest/tags/api-design.md?difficulty=easy))

## Keywords

OpenCode, Docker Model Runner, qwen3-coder, devstral-small-2, gpt-oss, OCI artifacts, Hugging Face, agents.md

## Related posts

- [Run Claude Code Locally with Docker Model Runner](https://swe.quest/articles/run-claude-code-locally-with-docker-model-runner-73b35fcd9b678964.md): Docker · 2026-01-26 · Medium · 4 min read · AI for coding, Inference & serving, LLMs, Developer tools
  Claude Code can run against local models by pointing its ANTHROPIC\_BASE\_URL environment variable at Docker Model Runner, which exposes an Anthropic-compatible API on localhost:12434.
- [Run LLMs Locally with Docker: A Quickstart Guide to Model Runner](https://swe.quest/articles/run-llms-locally-with-docker-a-quickstart-guide-to-model-runner-ccfbbb71db5d1485.md): Docker · 2025-04-04 · Medium · 5 min read · Inference & serving, LLMs, Containers, Developer tools
  Docker Model Runner, in beta with Docker Desktop 4.40 on Apple silicon, pulls LLMs packaged as OCI artifacts and serves them through an OpenAI-compatible API backed by llama.cpp.
- [How to Build, Run, and Package AI Models Locally with Docker Model Runner](https://swe.quest/articles/how-to-build-run-and-package-ai-models-locally-with-docker-model-runner-acbc6d65548e5373.md): Docker · 2025-06-12 · Medium · 6 min read · Inference & serving, LLMs, Containers, Developer tools
  Docker Model Runner, enabled as a beta feature in Docker Desktop 4.40+, pulls GGUF-format LLMs from Docker Hub or Hugging Face and runs them locally via the \`docker model\` CLI or an OpenAI-compatible HTTP endpoint on localhost.
- [Run Gemma 3 with Docker Model Runner: Fully Local GenAI Developer Experience](https://swe.quest/articles/run-gemma-3-with-docker-model-runner-fully-local-genai-developer-experience-c005339b3915484f.md): Docker · 2025-04-09 · Medium · 7 min read · LLMs, Inference & serving, Containers, JavaScript
  Docker Model Runner (in Docker Desktop for macOS 4.40.0+) exposes an OpenAI-compatible API on localhost, so Gemma 3 can be pulled with \`docker model pull ai/gemma3\` and called through the standard OpenAI SDK by pointing baseURL at http://localhost:12434/engines/v1.
- [Docker Model Runner on the new NVIDIA DGX Spark: a new paradigm for developing AI locally](https://swe.quest/articles/docker-model-runner-on-the-new-nvidia-dgx-spark-a-new-paradigm-for-developing-f03f09cdcb90d612.md): Docker · 2025-10-14 · Medium · 7 min read · Inference & serving, Containers, LLMs, AI for coding, Hardware
  Docker Model Runner now supports NVIDIA DGX Spark, a compact Grace Blackwell GB10 workstation with 128GB of unified memory, for running large models locally.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
