forked from open-webui/open-webui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-ollama.sh
More file actions
executable file
·37 lines (28 loc) · 1016 Bytes
/
Copy pathdocker-ollama.sh
File metadata and controls
executable file
·37 lines (28 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
set -euo pipefail
# ---------------------------------------------------------------------------
# Pull and run the official Ollama container with optional GPU support.
# ---------------------------------------------------------------------------
readonly CONTAINER="ollama"
readonly HOST_PORT="${OLLAMA_PORT:-11434}"
readonly CONTAINER_PORT=11434
read -rp "Enable GPU passthrough? [y/N]: " use_gpu
echo "Pulling latest Ollama image..."
docker pull ollama/ollama:latest
echo "Stopping any existing ${CONTAINER} container..."
docker rm -f "$CONTAINER" 2>/dev/null || true
gpu_flags=()
if [[ "${use_gpu,,}" =~ ^y(es)?$ ]]; then
gpu_flags=("--gpus=all")
echo "GPU passthrough enabled."
fi
echo "Starting ${CONTAINER}..."
docker run -d \
"${gpu_flags[@]}" \
-v "ollama:/root/.ollama" \
-p "${HOST_PORT}:${CONTAINER_PORT}" \
--name "$CONTAINER" \
ollama/ollama
echo "Cleaning up dangling images..."
docker image prune -f
echo "Ollama is running at http://localhost:${HOST_PORT}"