Skip to content

Docker Integration

CodeBuddy integrates with Docker for running local AI models and managing MCP servers. This covers three capabilities: Docker Model Runner for GPU-accelerated inference, Ollama containers via docker-compose, and the MCP Docker Gateway for unified tool catalogs.

Docker Model Runner is Docker Desktop’s built-in inference engine. CodeBuddy can enable it, pull models, and route requests to it automatically.

  1. Ensure Docker Desktop is installed and running
  2. In CodeBuddy, use the Docker panel or ask the agent: “Enable Docker Model Runner”

This runs:

Terminal window
docker desktop enable model-runner --tcp=12434

Models are then accessible at http://localhost:12434/engines/llama.cpp/v1 (OpenAI-compatible API).

ActionCLI equivalent
List modelsdocker model ls --json
Pull a modeldocker model pull <name>
Delete a modeldocker model rm <name>
Use a modelAuto-configures local.model, local.baseUrl, and switches to Local provider

When you select “Use Model”, CodeBuddy tries Docker Model Runner on port 12434 first (1-second timeout). If unavailable, it falls back to Ollama on port 11434. The appropriate local.baseUrl is set automatically.

CodeBuddy bundles a docker-compose.yml for running Ollama in a container:

# Key settings:
# - 32 GB memory limit
# - GPU passthrough (optional)
# - Persistent volume for models
# - Port 11434 exposed

Start with: “Start Ollama container” or via the Docker panel.

Terminal window
docker compose -f <extension-path>/docker-compose.yml up -d
ActionCLI equivalent
Check statusdocker ps --filter name=ollama --format json
List modelsdocker exec ollama ollama list
Pull a modeldocker exec ollama ollama pull <name>

CodeBuddy probes the Docker socket directly (/var/run/docker.sock on macOS/Linux, \\.\pipe\docker_engine on Windows) to check if Docker is running. Results are cached for 15 seconds to avoid repeated spawn failures.

The MCP Docker Gateway provides a unified catalog of MCP tools from a single Docker-managed endpoint.

  1. CodeBuddy detects the Docker Gateway via docker mcp --help + docker info
  2. When docker-gateway is the only enabled MCP server, all MCP tools come from one unified catalog
  3. Communication uses stdio or SSE transport
FeatureBehavior
Circuit breaker3 failures → 5-minute cooldown per server
Idle shutdownGateway disconnects after 5 minutes of inactivity, reconnects on-demand
macOS PATH fixupInjects /usr/local/bin:/opt/homebrew/bin etc. for proper CLI discovery
Graceful degradationIf Docker is unavailable, the agent continues with core tools only

The Docker panel in the CodeBuddy webview exposes 10 operations:

CommandDescription
docker-enable-runnerEnable Docker Model Runner
docker-start-composeStart Ollama container
docker-check-statusCheck Docker availability
docker-check-ollama-statusCheck Ollama container status
docker-get-modelsList all local models
docker-get-local-modelGet current local model config
docker-pull-modelPull a Docker model
docker-pull-ollama-modelPull an Ollama model
docker-delete-modelDelete a model
docker-use-modelSwitch to a model (with port fallback)

Docker commands executed through the terminal are strictly whitelisted. Only these argument patterns pass validation:

  • Model operations: model ls, model pull <name>, model rm <name>
  • Container operations: ps --filter name=ollama, compose up -d, exec ollama ollama list
  • MCP operations: mcp server ls, mcp gateway run
  • Setup: desktop enable model-runner --tcp=12434

Model names are validated against /^[a-zA-Z0-9/:\-.]+$/ to prevent injection.

Docker integration uses existing local model settings — there are no Docker-specific settings:

SettingDescription
local.modelModel name (auto-set when using “Use Model”)
local.baseUrlEndpoint URL (auto-set with port fallback)
generativeAi.optionSet to "Local" when switching to a Docker model

See Local Models for the full local model setup guide.