Skip to main content

Ollama

What is Ollama?

Ollama runs open LLMs locally and exposes an OpenAI-compatible HTTP API, giving PHP apps local inference with no external calls or per-token cost. Point Prism, Neuron AI, LLPhant, or openai-php at it, and pair it with pgvector for fully local RAG.

Start Ollama

./laradock start ollama

Stop Ollama

Stopping just pauses the container; downloaded models are safe (they live in the ollama Docker volume, not in the container itself):

./laradock stop ollama

To delete the container entirely (the ollama volume, and every model in it, is still untouched):

./laradock remove ollama

Configuration

All settings live in ollama/defaults.env and can be overridden by adding the same line to your own .env:

VariableDefaultWhat it does
OLLAMA_VERSIONlatestImage tag from the ollama/ollama Docker Hub image.
OLLAMA_HOST_PORT11434Host-side port Ollama is published on (container port 11434).

Models are stored in the ollama named Docker volume at /root/.ollama, not under DATA_PATH_HOST, so they persist across container restarts but aren't visible directly on your host filesystem.

Pull, list, and remove models

No model is downloaded by default, pull one before your first request:

./laradock exec ollama ollama pull llama3.2

See everything you've already downloaded:

./laradock exec ollama ollama list

See which models are currently loaded into memory and answering requests:

./laradock exec ollama ollama ps

Free up disk space by removing a model you no longer need:

./laradock exec ollama ollama rm llama3.2

Use the API

The API is at http://localhost:11434 from your host, or http://ollama:11434 from other containers. It's OpenAI-compatible under http://ollama:11434/v1, so most OpenAI PHP SDKs work by just pointing the base URL there.

Enable GPU acceleration

Ollama's compose.yml runs CPU-only by default, no GPU is reserved for it. If your host has an NVIDIA GPU with the NVIDIA Container Toolkit installed, add a device reservation to ollama/compose.yml:

services:
ollama:
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]

Apply it with ./laradock rebuild ollama and ./laradock restart ollama. Without this, larger models fall back to CPU inference, which is noticeably slower.

Start completely fresh (wipe all models)

To throw away every downloaded model and start from a clean volume (this permanently deletes everything in the ollama volume):

./laradock stop ollama
./laradock remove ollama
docker volume ls | grep ollama
docker volume rm <the-name-you-found-above>
./laradock start ollama

The volume name is prefixed with your project name (COMPOSE_PROJECT_NAME), so it's usually something like <project>_ollama, docker volume ls | grep ollama shows the exact name on your machine. Removing individual models with ollama rm (above) is safer and usually all you need, only wipe the whole volume if you want a truly clean slate.

Talk to Ollama from another Laradock project

Each Laradock project is its own isolated Docker network by default, so a second project's containers can't reach this Ollama by container name out of the box. Since the port is already published (OLLAMA_HOST_PORT), point the other project at your host machine's address instead of ollama, for example http://host.docker.internal:11434 (Docker Desktop). Make sure the two projects use different OLLAMA_HOST_PORT values if they're both running at once, running one shared Ollama for multiple projects saves you from downloading the same multi-GB models twice.

Common issues

  • First request after starting is slow or fails. No model is pulled by default, run ./laradock exec ollama ollama pull <model> first; the pull itself can take a while depending on model size and your connection.
  • Out of disk space. Models are large (several GB each) and accumulate in the ollama volume. Remove unused ones with ./laradock exec ollama ollama rm <model>.
  • CPU-only inference is slow. Ollama uses GPU acceleration when available; see Enable GPU acceleration above.
  • App can't connect but the container is running. Use the container name ollama, not localhost, from inside another container.

Need a unified gateway across multiple LLM providers instead? See LiteLLM. Need an OpenAI-compatible server with more model formats? See LocalAI. New to Laradock? Start with Getting Started.