sbx/claude-ollama是适配Sandbox Kit的工具镜像,可将Claude Code的API请求路由到本地Ollama实例,支持自定义本地模型,满足离线开发、免成本大模型调试需求。
[!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 insbx.
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.internalrequires 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 ofhost.docker.internal.
Usage
consolesbx run "docker.io/sbx/claude-ollama:latest" ~/my-project
Or from a git URL or a local clone of this repo:
consolesbx 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:
- Sets
ANTHROPIC_BASE_URLtohttp://host.docker.internal:11434(Ollama via Docker's host bridge) - Uses a dummy
ANTHROPIC_AUTH_TOKEN— Ollama doesn't require real credentials - Maps every Claude model alias (Opus, Sonnet, Haiku, sub-agent) to
$CLAUDE_OLLAMA_MODEL - 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.
sbx 命名空间的其他可用镜像:
sbx/opencode
sbx/hermes-agent-image
sbx/pi-image
sbx/shell
sbx/claude
sbx/playwright
镜像拉取方式
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
轩辕镜像加速拉取命令点我查看更多 claude-ollama 镜像标签
DockerHub 原生拉取命令
用户好评
来自真实用户的反馈,见证轩辕镜像的优质服务