Skip to content

Instantly share code, notes, and snippets.

@hunzo
Last active April 8, 2026 04:25
Show Gist options
  • Select an option

  • Save hunzo/7704d65804ab2f4d3c132e3f8f865326 to your computer and use it in GitHub Desktop.

Select an option

Save hunzo/7704d65804ab2f4d3c132e3f8f865326 to your computer and use it in GitHub Desktop.
config olllama on docker and opencode

Config Ollam + Opencode

Config Opencode

  • .config/opencode/config.json
{
    "$schema": "https://opencode.ai/config.json",
    "default_agent": "build",
    "compaction": {
        "auto": true,
        "prune": true,
        "reserved": 8192
    },
    "provider": {
        "ollama": {
            "name": "Ollama",
            "npm": "@ai-sdk/openai-compatible",
            "options": {
                "baseURL": "http://localhost:11434/v1"
            },
            "models": {
                "gemma4:e4b-32k": {
                    "name": "gemma4:e4b-32k",
                    "_launch": true,
                    "id": "gemma4:e4b-32k",
                    "tool_call": true,
                    "options": {
                        "temperature": 0.1
                    },
                    "maxTokens": 16384
                },
                "gemma4:e2b": {
                    "name": "gemma4:e2b",
                    "_launch": true,
                    "id": "gemma4:e2b",
                    "tool_call": true,
                    "options": {
                        "temperature": 0.1
                    },
                    "maxTokens": 16384
                }
            }
        }
    }
}

Docker compose file

services:
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    restart: unless-stopped
    runtime: nvidia
    ports:
      - "11434:11434"
    volumes:
      - ollama_data:/root/.ollama
    command: ["serve"]
volumes:
  ollama_data:

Example Pull Model

  • pull model
docker compose exec ollama ollama pull gemma4:e4b
  • config model
docker compose exec ollama ollama run gemma4:e4b

# then within the Ollama model prompt run these commands:

/set parameter num_ctx 32768
/save gemma4:e4b-32k
/bye

# then confirm the new model is in place

docker compose exec ollama ollama list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment