compose: declare ollama_data as external to silence adoption warning
Some checks failed
CI / ruff (push) Has been cancelled
CI / mypy --strict (push) Has been cancelled
CI / pytest (push) Has been cancelled
CI / bandit (push) Has been cancelled
CI / pip-audit (push) Has been cancelled

Every `docker compose up` was printing:

    WARN volume "neuro-api_neuro-ollama-data" already exists but was
    created for project "neuro-api" (expected "neuro-gateway"). Use
    `external: true` to use an existing volume

That's exactly the situation we're in by design: the ollama volume is
owned by a NEIGHBORING compose stack (neuro-api or neuro-ollama,
depending on the host) and our gateway intentionally adopts it. The
warning fires because compose was managing the volume under our project
namespace even though the on-disk volume belongs to a different one.

Declaring `external: true` on `ollama_data` (and only that volume —
`postgres_data` stays compose-managed, since it belongs to this stack)
tells compose: "this volume is foreign, just attach it as-is, don't
namespace-check it." Warning gone, behavior identical.

Trade-off documented in the comment: `external: true` requires the
volume to exist before `up`. For fresh deployments where no foreign
Ollama volume exists, run `docker volume create <name>` first (or set
OLLAMA_DATA_VOLUME to a name you've already created).
This commit is contained in:
Stephan Berbig
2026-05-27 22:34:45 +02:00
parent 653e03bf29
commit b8a0692aa1

View File

@@ -136,7 +136,14 @@ volumes:
# Override via .env if your existing volumes are named differently: # Override via .env if your existing volumes are named differently:
# POSTGRES_DATA_VOLUME=neuro-api_postgres-data # POSTGRES_DATA_VOLUME=neuro-api_postgres-data
# OLLAMA_DATA_VOLUME=neuro-ollama_ollama-data # OLLAMA_DATA_VOLUME=neuro-ollama_ollama-data
# postgres_data is owned by THIS stack — created on first up, no external flag.
postgres_data: postgres_data:
name: ${POSTGRES_DATA_VOLUME:-neuro-gateway_postgres_data} name: ${POSTGRES_DATA_VOLUME:-neuro-gateway_postgres_data}
# ollama_data is intentionally ADOPTED from another stack (e.g. neuro-api /
# neuro-ollama). external: true tells compose "yes, that volume belongs to a
# different project — use it as-is". This silences the project-namespace
# warning. The volume MUST already exist (create with `docker volume create
# <name>` if you ever deploy fresh and the foreign one isn't there).
ollama_data: ollama_data:
external: true
name: ${OLLAMA_DATA_VOLUME:-neuro-gateway_ollama_data} name: ${OLLAMA_DATA_VOLUME:-neuro-gateway_ollama_data}