#!/bin/bash # Expose Ollama on all interfaces so Docker containers (AnythingLLM) can reach it via # host.docker.internal (--add-host=host.docker.internal:host-gateway). # Requires sudo. Idempotent. set -euo pipefail if [ "$(id -u)" -ne 0 ]; then echo "Run: sudo $0" >&2 exit 1 fi mkdir -p /etc/systemd/system/ollama.service.d cat <<'EOF' > /etc/systemd/system/ollama.service.d/override.conf [Service] Environment="OLLAMA_HOST=0.0.0.0:11434" EOF systemctl daemon-reload systemctl restart ollama echo "Ollama listens on 0.0.0.0:11434 (check: ss -tlnp | grep 11434)"