Fix Docker container to run as host user and use host .ollama directory

This change prevents permission issues when using Ollama both locally and
in Docker by:
- Running container as host user (UID/GID) instead of root
- Mounting host's $HOME/.ollama directory using environment variables
- Setting HOME environment variable in container

This allows both the local binary and Docker container to share the same
model data without permission conflicts or duplication.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Shang Chieh Tseng
2025-11-09 18:00:42 +08:00
parent 8380ca93f8
commit 0293c53746

View File

@@ -5,6 +5,7 @@ services:
image: ollama37-runtime:latest
container_name: ollama37-runtime
runtime: nvidia
user: "${UID:-1000}:${GID:-1000}"
deploy:
resources:
reservations:
@@ -15,8 +16,9 @@ services:
ports:
- "11434:11434"
volumes:
- ollama-data:/root/.ollama
- ${HOME}/.ollama:${HOME}/.ollama
environment:
- HOME=${HOME}
- OLLAMA_HOST=0.0.0.0:11434
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility