ollama-layer
Recipe card from the charly-ollama plugin (Images — the deployable catalog).
ollama – Local LLM inference server
Section titled “ollama – Local LLM inference server”Candy Properties
Section titled “Candy Properties”| Property | Value |
|---|---|
| Dependencies | supervisord |
| Ports | 11434 |
| Volumes | models -> ~/.ollama |
| Aliases | ollama -> ollama |
| Service | ollama (supervisord) — a charly-owned wrapper that runs ollama serve and rides the default-model pull |
| Install | the packaged ollama via distro: where the distro ships one (Arch and its derivatives), else a download: + extract: plan step gated on unless_exists: |
Environment Variables
Section titled “Environment Variables”| Variable | Value |
|---|---|
OLLAMA_HOST |
0.0.0.0 |
OLLAMA_MODELS |
~/.ollama/models |
OLLAMA_PULL_MODELS |
empty — a space-separated list of model ids the pod carries as its DEFAULTS |
OLLAMA_GPU_MIN_FREE_MIB |
512 — free VRAM the wrapper waits for before starting the server; 0 disables the gate |
OLLAMA_GPU_WAIT_SECONDS |
600 — the gate’s deadline |
Default models (OLLAMA_PULL_MODELS)
Section titled “Default models (OLLAMA_PULL_MODELS)”The candy ships the MECHANISM, not a list. OLLAMA_PULL_MODELS is a
space-separated list of model ids; the service runs a charly-owned wrapper
(/opt/ollama/start-ollama.sh) that starts ollama serve and, when the list is
non-empty, rides a background pull beside it — bounded wait for the API, then an
idempotent ollama pull per id. It is EMPTY here on purpose: this candy is also
composed by CPU-only consumers (openclaw-desktop and friends), and a default
list at this layer would make every one of them start downloading gigabytes. Set
it one layer up:
# a GPU box, or a deploy entry that overrides the image envenv: OLLAMA_PULL_MODELS: "qwen3-vl:2b-instruct-q4_K_M lfm3-vl:2b-qad-q4_0"The store is the persistent models volume, so the download happens once per
host; ollama pull is idempotent, so later starts are no-ops. An empty value is a
no-op. A disposable bed should override the box default with one small model so it
never pays the full download.
Why the pull rides with the server instead of being its own one-shot program.
The rendered supervisord fragment has no startsecs, and supervisord marks any
exit before startsecs (default 1s) as a failed start (BACKOFF, “Exited too
quickly”) regardless of autorestart — an immediate-exit program would retry
startretries times and go FATAL. type: oneshot and start_sec are in the
schema but the supervisord template does not render them. Riding with the server
also keeps ONE supervised process, so a failed pull (network) never changes the
server’s supervisor state: it logs to the container log and the next start retries
it.
GPU readiness gate (never silently CPU-only)
Section titled “GPU readiness gate (never silently CPU-only)”ollama serve decides GPU availability ONCE, at startup: it creates a CUDA context
and reads the device’s memory. Under VRAM pressure (a co-tenant holding the card)
that context creation fails, llama-server reports zero memory for the device,
ollama logs skipping pseudo-device with zero memory, and the server runs CPU-ONLY
for its whole lifetime — even after the VRAM frees. Measured on this pod: a restart
while a co-tenant held the GPU produced inference compute id=cpu library=cpu, and
it never recovered without a restart.
The wrapper therefore gates the start: when an NVIDIA device is passed into the pod
(/dev/nvidiactl exists) and nvidia-smi is available, it waits until some GPU
reports at least OLLAMA_GPU_MIN_FREE_MIB (default 512) MiB free, up to
OLLAMA_GPU_WAIT_SECONDS (default 600). On timeout it exits non-zero and prints
why — supervisord restarts the wrapper, which re-runs the gate — instead of
starting a CPU-only server on a GPU pod. A CPU-only consumer has no
/dev/nvidiactl, so the gate returns immediately and the candy stays GPU-agnostic:
it DETECTS a device, it does not declare one. Set OLLAMA_GPU_MIN_FREE_MIB: "0" to
allow a deliberate CPU fallback under contention.
512 MiB is enough for the discovery context, which is all the gate has to buy; per-model loading already degrades to partial offload on its own when memory is tighter.
Build-time Variables (var:)
Section titled “Build-time Variables (var:)”| Variable | Default | Purpose |
|---|---|---|
OLLAMA_VERSION |
v0.40.17 |
Upstream release for the TARBALL path only, and it must be a release TAG — the download cache is content-addressed by the sha256 of the URL, so a latest URL would hash to one key forever and keep serving the first tarball it ever fetched. Ignored on Arch, where the packaged ollama is installed and pacman owns the version |
GPU backends (opt-in, box level)
Section titled “GPU backends (opt-in, box level)”On a distro that PACKAGES ollama the candy itself is CPU-only, and a box adds a backend by composing one of the sibling candies — which is what keeps a CPU image small. On a TARBALL distro the single upstream archive already contains the CUDA backend, so there is nothing to opt out of there; ROCm is never in it:
| Candy | Adds | Installed size |
|---|---|---|
ollama-cuda |
NVIDIA CUDA backend (libggml-cuda.so) |
~496 MiB |
ollama-rocm |
AMD ROCm/HIP backend (libggml-hip.so) |
~1.0 GiB |
Both figures are each package’s OWN installed size (pacman’s size =, from the
0.40.16 packages), and neither includes that package’s dependencies —
ollama-cuda depends on cuda and ollama-rocm on hipblas, so a real image pays
more than the table says. The ROCm row is the one that moves most between ollama
releases (~2.9 GiB at v0.32.14, ~1.0 GiB at v0.40.16) — and it is the package’s
CONTENT that moved, not its dependency list, because both of those releases declare
the same hipblas dependency. Measure it per release rather than carrying a number
forward: tar --zstd -xOf ollama-rocm-<ver>-<rel>-x86_64.pkg.tar.zst .PKGINFO.
Both are the split Arch packages: each depends on ollama and drops its backend
into the same /usr/lib/ollama/ runner directory rather than replacing anything.
Service Environment (injected into other containers)
Section titled “Service Environment (injected into other containers)”| Variable | Template Value | Resolved Example |
|---|---|---|
OLLAMA_HOST |
http://{{.ContainerName}}:11434 |
http://charly-ollama:11434 |
Pod-aware: same-container consumers receive http://localhost:11434, cross-container consumers receive http://charly-ollama:11434. When charly config ollama runs, OLLAMA_HOST is automatically injected into the global charly.yml env. Use charly config ollama --update-all to propagate to already-deployed services immediately.
See /charly-image:layer for env_provide field docs and /charly-core:charly-config for --update-all.
ollama: candy: - ollamacharly alias install ollama # install host 'ollama' commandollama run llama3 # uses the aliasUsed In Boxes
Section titled “Used In Boxes”Cross-Container Integration
Section titled “Cross-Container Integration”The env_provide mechanism makes OLLAMA_HOST available to all containers. The hermes candy auto-detects this variable and configures itself to use local Ollama as its LLM provider (highest priority in the auto-detection chain: OLLAMA_HOST > OLLAMA_API_KEY > OPENROUTER_API_KEY). See /charly-hermes:hermes for details on the auto-provider-configuration.
The candy ships its acceptance steps in its plan:,
baked into the ai.opencharly.description OCI label (see /charly-check:check
for the full schema). Each step is one inline Op — a probe is a check:
step — and its context: list gates where it runs:
-
ungated (no
context:, so it runs wherever the plan runs):/usr/bin/ollamaexistsollama --versionoutput contains the pinned release (0.40.17),id: ollama-version-pinned— the ONE probe that can go red on anOLLAMA_VERSIONbump, because every other step here passes at ANY upstream version. It carriesexclude_distro: [arch, cachyos], so it SKIPS on the packaged path, where pacman owns the version and this candy’s pin does not bind. That skip is the design, not a missing assertion.
-
context: [runtime](run against a live service; uses127.0.0.1:${HOST_PORT:11434}— the host-side form, not${CONTAINER_IP}, so port remapping works unchanged):GET http://127.0.0.1:${HOST_PORT:11434}/api/tagsreturns 200ollama --versionstdout matches^ollama versionollama listexits 0 against the live service- three HOST-side steps (
in_container: false) driving${CHARLY_BIN}, which prove the companioncommand:ollamaplugin end to end:charly ollama helpdispatches,charly ollama versionround-trips the live API, andcharly ollama listreads the model table. These three DO carryid:keys (ollama-cli-help,ollama-cli-version,ollama-cli-list); the steps above them do not, and are named here by what they assert rather than by an identifier the source does not define. They live on the candy rather than on any one bed, so every box composing ollama inherits them.
The plan also ends with an
agent-check:step covering model persistence across a service restart.
A composed backend candy adds its own build-scope probe — ollama-cuda asserts
libggml-cuda.so and ollama-rocm asserts libggml-hip.so, each globbed under
/usr/lib/ollama/*/ so a CUDA/ROCm version bump does not break the check.
Related Candies
Section titled “Related Candies”/charly-distros:cuda– CUDA toolkit; composed OUTSIDE this candy (today by the GPU boxes, at the image level) and never declared as its dependency/charly-infrastructure:supervisord– process manager dependency/charly-ollama:ollama-cli– the compiled-incharly ollamamanagement CLI (candy/plugin-ollama)/charly-openclaw:openclaw– AI gateway that can use Ollama as backend/charly-hermes:hermes– AI agent that auto-detectsOLLAMA_HOSTfor local Ollama provider
Related Commands
Section titled “Related Commands”/charly-core:charly-config— Deploy with quadlet (secrets, volumes, env_provide injection)/charly-core:start— Start the Ollama service/charly-core:service— Manage Ollama service inside container
When to Use This Skill
Section titled “When to Use This Skill”Use when the user asks about:
- Ollama setup or model management
- LLM serving or inference
- Port 11434 configuration
- Ollama model storage volume
- The
ollamahost alias

