claude-ollama

Claude Ollama Docker Image

sbx/claude-ollama是适配Sandbox Kit的工具镜像,可将Claude Code的API请求路由到本地Ollama实例,支持自定义本地模型,满足离线开发、免成本大模型调试需求。

下载次数: 0状态:社区镜像维护者:sbx仓库类型:镜像最近更新:
下载命令
点击查看

[!NOTE] Experimental: Sandbox Kit v3

This kit uses the experimental https://github.com/docker/sandbox-kit-spec, specifically https://github.com/docker/sandbox-kit-spec/blob/main/docs/spec/SPEC-v3.md. The format and runtime behavior may change before v3 is stable.

claude-ollama

ollama launch claude --model gemma4:e4b-it-q4_K_M — but in sbx.

A fork of the built-in claude agent that routes all API calls to a local Ollama instance instead of Anthropic's API. Useful for offline development, cost-free experimentation, or testing with custom local models.

Prerequisite: Ollama must be running on your host machine at its default port (localhost:11434) before starting this sandbox.

Linux hosts: host.docker.internal requires Docker to be started with --add-host=host.docker.internal:host-gateway. If Ollama is unreachable, verify this flag is set or use your host's LAN/bridge IP in place of host.docker.internal.

Usage

console
sbx run "docker.io/sbx/claude-ollama:latest" ~/my-project

Or from a git URL or a local clone of this repo:

console
sbx run "git+https://github.com/docker/sbx-kits-contrib.git#dir=claude-ollama" ~/my-project
sbx run ./claude-ollama/ ~/my-project

The workload reference passed to sbx run identifies the kit. A v3 descriptor carries no name: field; its matchable name is the claude-ollama entry under provides.

That name is also why the six requires: ["claude"] mixins in this repo do not compose onto this kit: it provides claude-ollama, which is exactly the boundary the v2 kit's own agent name drew.

The default model is gemma4:e4b-it-q4_K_M. To use a different model, override CLAUDE_OLLAMA_MODEL per sandbox, or fork this kit and change the ENV default in https://github.com/docker/sbx-kits-contrib/blob/v3/./claude-ollama.dockerfile.

For the same wiring as an overlay you can layer onto a base you want to keep, see https://github.com/docker/sbx-kits-contrib/blob/v3/../claude-ollama-mixin.

What changed vs the built-in claude

Instead of calling api.anthropic.com, a wrapper script replaces the entrypoint. Under v3 the entrypoint lives in the image config, where OCI already carries the runtime contract, so the swap happens in the recipe:

diff
-ENTRYPOINT ["claude", "--dangerously-skip-permissions"]
+ENTRYPOINT ["/home/agent/.local/bin/claude-ollama"]

The wrapper itself is written by a lifecycle files: entry, which the runtime lands before the entrypoint first runs.

The wrapper script:

  1. Sets ANTHROPIC_BASE_URL to http://host.docker.internal:11434 (Ollama via Docker's host bridge)
  2. Uses a dummy ANTHROPIC_AUTH_TOKEN — Ollama doesn't require real credentials
  3. Maps every Claude model alias (Opus, Sonnet, Haiku, sub-agent) to $CLAUDE_OLLAMA_MODEL
  4. Calls exec claude "$@" — the real Claude Code CLI takes over from there

Reference: https://github.com/ollama/ollama/blob/8f39fff70bac0bef2370a6af7020efa29a6a7cad/cmd/launch/claude.go

Network access is restricted to host.docker.internal:11434 only — that hostname, not localhost, is what egress filtering sees — and no Anthropic API domain is reachable. The port suffix is kept deliberately rather than following this repo's portless house style: host.docker.internal is the host itself, so dropping it would widen the grant from one local model server to every port the host has open.

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 claude-ollama 镜像标签

docker pull docker.xuanyuan.run/sbx/claude-ollama:<标签>

DockerHub 原生拉取命令

docker pull sbx/claude-ollama:<标签>
专业版 · 高速稳定拉取镜像
50GB 仅 ¥8/年
高速镜像下载在线技术支持专业版保障服务可用付费会员免广告