🗃️ Removed the .claude/settings.local.json 🗃️

Dockerfile
.env.scripts
.gitea/workflows/docker.yaml
.gitignore
README.md
rootfs/usr/local/bin/entrypoint.sh
rootfs/usr/local/bin/pkmgr
This commit is contained in:
2026-05-12 20:07:46 -04:00
parent 5a17673832
commit dfc29781c6
7 changed files with 92 additions and 715 deletions
+9 -8
View File
@@ -25,11 +25,12 @@ DOCKER_ENTYPOINT_HEALTH_ENDPOINTS="$DOCKER_ENTYPOINT_HEALTH_ENDPOINTS"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Dockerfile info
ENV_DOCKERFILE="Dockerfile"
ENV_IMAGE_NAME="ollama"
ENV_USE_TEMPLATE="debian"
# ENV_REGISTRY_REPO: Registry repository/image name
ENV_REGISTRY_REPO="ollama"
ENV_USE_TEMPLATE="alpine"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Maintainer info
ENV_ORG_NAME="casjaysdevdocker"
ENV_REGISTRY_ORG="casjaysdevdocker"
ENV_VENDOR="CasjaysDev"
ENV_AUTHOR="CasjaysDev"
ENV_MAINTAINER="CasjaysDev <docker-admin@casjaysdev.pro>"
@@ -37,12 +38,12 @@ ENV_MAINTAINER="CasjaysDev <docker-admin@casjaysdev.pro>"
# Repository URLs (Full URLs)
# ENV_GIT_REPO_URL: Complete Git repository URL for source code
ENV_GIT_REPO_URL="https://github.com/casjaysdevdocker/ollama"
# ENV_REGISTRY_URL: Complete registry URL for reference (NOT used for pushing)
ENV_REGISTRY_URL="https://hub.docker.com/casjaysdevdocker/ollama"
# ENV_REGISTRY_URL: Registry provider base URL (for example https://docker.io)
ENV_REGISTRY_URL="https://docker.io"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Push Configuration
# ENV_IMAGE_PUSH: Complete push destination (this IS used for pushing)
ENV_IMAGE_PUSH="casjaysdevdocker/ollama"
# ENV_REGISTRY_PUSH: Complete push destination derived from registry/org/repo
ENV_REGISTRY_PUSH="casjaysdevdocker/ollama"
# ENV_IMAGE_TAG: Default tag for the image
ENV_IMAGE_TAG="latest"
# ENV_ADD_TAGS: Additional tags, comma-separated (USE_DATE = auto date tag)
@@ -55,7 +56,7 @@ ENV_ADD_IMAGE_PUSH=""
# ENV_PULL_URL: Source image to pull from (base image)
ENV_PULL_URL="debian"
# ENV_DISTRO_TAG: Tag for the pull source image
ENV_DISTRO_TAG="bookworm"
ENV_DISTRO_TAG="${IMAGE_VERSION}"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Env
SERVICE_PORT="11434"
+15 -7
View File
@@ -19,13 +19,20 @@ jobs:
- name: Get Meta
id: meta
run: |
echo DATE_TAG=$(date +'%y%m') >> $GITHUB_OUTPUT
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
echo DOCKER_ORG=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $1}') >> $GITHUB_OUTPUT
echo DOCKER_TAG=$([ -n "$DOCKER_TAG" ] && echo ${DOCKER_TAG} || echo "latest") >> $GITHUB_OUTPUT
echo DOCKER_HUB=$([ -n "$DOCKER_HUB" ] && echo ${DOCKER_HUB} || echo "docker.io") >> $GITHUB_OUTPUT
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | sed 's|^docker-||g') >> $GITHUB_OUTPUT
echo "$DOCKER_HUB/$DOCKER_ORG/$REPO_NAME:$DOCKER_TAG"
repo_version="$(git describe --tags --always)"
repo_version="${repo_version#v}"
docker_org="${GITHUB_REPOSITORY%%/*}"
repo_name="${GITHUB_REPOSITORY#*/}"
repo_name="${repo_name#docker-}"
docker_tag="${DOCKER_TAG:-latest}"
docker_hub="${DOCKER_HUB:-docker.io}"
printf 'DATE_TAG=%s\n' "$(date +'%y%m')" >> "$GITHUB_OUTPUT"
printf 'REPO_VERSION=%s\n' "$repo_version" >> "$GITHUB_OUTPUT"
printf 'DOCKER_ORG=%s\n' "$docker_org" >> "$GITHUB_OUTPUT"
printf 'DOCKER_TAG=%s\n' "$docker_tag" >> "$GITHUB_OUTPUT"
printf 'DOCKER_HUB=%s\n' "$docker_hub" >> "$GITHUB_OUTPUT"
printf 'REPO_NAME=%s\n' "$repo_name" >> "$GITHUB_OUTPUT"
printf '%s\n' "$docker_hub/$docker_org/$repo_name:$docker_tag"
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v2
@@ -58,3 +65,4 @@ jobs:
tags: |
${{ steps.meta.outputs.DOCKER_HUB }}/${{ steps.meta.outputs.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.DATE_TAG }}
${{ steps.meta.outputs.DOCKER_HUB }}/${{ steps.meta.outputs.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.DOCKER_TAG }}
+1 -1
View File
@@ -1,4 +1,4 @@
# gitignore created on 01/28/26 at 23:19
# gitignore created on 05/05/26 at 14:38
# Disable reminder in prompt
ignoredirmessage
+24 -16
View File
@@ -1,4 +1,4 @@
# Docker image for ollama using the debian template
# Docker image for ollama using the alpine template
ARG IMAGE_NAME="ollama"
ARG PHP_SERVER="ollama"
ARG BUILD_DATE="202601291418"
@@ -25,13 +25,12 @@ ARG IMAGE_VERSION="latest"
ARG CONTAINER_VERSION=""
ARG PULL_URL="debian"
ARG DISTRO_VERSION="bookworm"
ARG DISTRO_VERSION="${IMAGE_VERSION}"
ARG BUILD_VERSION="${BUILD_DATE}"
FROM tianon/gosu:latest AS gosu
FROM ${PULL_URL}:${DISTRO_VERSION} AS build
ARG TZ
ARG PATH
ARG USER
ARG LICENSE
ARG TIMEZONE
@@ -53,7 +52,7 @@ ARG NODE_MANAGER
ARG PHP_VERSION
ARG PHP_SERVER
ARG SHELL_OPTS
ARG DEBIAN_FRONTEND
ARG PATH
ARG PACK_LIST="curl ca-certificates gnupg tini procps libopenblas0 libgomp1 zstd wget software-properties-common gnupg2 gpg"
@@ -63,10 +62,8 @@ ENV PATH="${PATH}"
ENV TZ="${TIMEZONE}"
ENV TIMEZONE="${TZ}"
ENV LANG="${LANGUAGE}"
ENV LC_ALL="${LANGUAGE}"
ENV TERM="xterm-256color"
ENV HOSTNAME="casjaysdevdocker-ollama"
ENV DEBIAN_FRONTEND="${DEBIAN_FRONTEND}"
USER ${USER}
WORKDIR /root
@@ -79,7 +76,13 @@ RUN set -e; \
RUN set -e; \
echo "Setting up prerequisites"; \
true
apk --no-cache add bash; \
SH_CMD="$(which sh 2>/dev/null||command -v sh 2>/dev/null)"; \
BASH_CMD="$(which bash 2>/dev/null||command -v bash 2>/dev/null)"; \
[ -x "$BASH_CMD" ] && symlink "$BASH_CMD" "/bin/sh" || true; \
[ -x "$BASH_CMD" ] && symlink "$BASH_CMD" "/usr/bin/sh" || true; \
[ -x "$BASH_CMD" ] && [ "$SH_CMD" != "/bin/sh" ] && symlink "$BASH_CMD" "$SH_CMD" || true; \
[ -n "$BASH_CMD" ] && sed -i 's|root:x:.*|root:x:0:0:root:/root:'$BASH_CMD'|g' "/etc/passwd" || true
ENV SHELL="/bin/bash"
SHELL [ "/bin/bash", "-c" ]
@@ -94,7 +97,12 @@ RUN echo "Initializing the system"; \
RUN echo "Creating and editing system files "; \
$SHELL_OPTS; \
[ -f "/root/.profile" ] || touch "/root/.profile"; \
rm -Rf "/etc/apk/repositories"; \
[ "$DISTRO_VERSION" = "latest" ] && DISTRO_VERSION="edge";[ "$DISTRO_VERSION" = "edge" ] || DISTRO_VERSION="v${DISTRO_VERSION}"; \
echo "http://dl-cdn.alpinelinux.org/alpine/${DISTRO_VERSION}/main" >>"/etc/apk/repositories"; \
echo "http://dl-cdn.alpinelinux.org/alpine/${DISTRO_VERSION}/community" >>"/etc/apk/repositories"; \
if [ "${DISTRO_VERSION}" = "edge" ]; then echo "http://dl-cdn.alpinelinux.org/alpine/${DISTRO_VERSION}/testing" >>"/etc/apk/repositories";fi; \
apk update; apk upgrade --no-cache; \
if [ -f "/root/docker/setup/01-system.sh" ];then echo "Running the system script";/root/docker/setup/01-system.sh||{ echo "Failed to execute /root/docker/setup/01-system.sh" >&2 && exit 10; };echo "Done running the system script";fi; \
echo ""
@@ -121,7 +129,7 @@ RUN echo "Updating system files "; \
echo 'hosts: files dns' >"/etc/nsswitch.conf"; \
[ "$PHP_VERSION" = "system" ] && PHP_VERSION="php" || true; \
PHP_BIN="$(command -v ${PHP_VERSION} 2>/dev/null || true)"; \
PHP_FPM="$(ls /usr/*bin/php*fpm* 2>/dev/null || true)"; \
set -- /usr/*bin/php*fpm*; [ -e "$1" ] && PHP_FPM="$1" || PHP_FPM=""; \
pip_bin="$(command -v python3 2>/dev/null || command -v python2 2>/dev/null || command -v python 2>/dev/null || true)"; \
py_version="$(command $pip_bin --version | sed 's|[pP]ython ||g' | awk -F '.' '{print $1$2}' | grep '[0-9]' || true)"; \
[ "$py_version" -gt "310" ] && pip_opts="--break-system-packages " || pip_opts=""; \
@@ -138,7 +146,7 @@ RUN echo "Updating system files "; \
RUN echo "Custom Settings"; \
$SHELL_OPTS; \
echo ""
echo ""
RUN echo "Setting up users and scripts "; \
$SHELL_OPTS; \
@@ -155,11 +163,10 @@ RUN echo "Setting OS Settings "; \
RUN echo "Custom Applications"; \
$SHELL_OPTS; \
echo ""
echo ""
RUN echo "Running custom commands"; \
$SHELL_OPTS; \
if [ -f "/root/docker/setup/05-custom.sh" ];then echo "Running the custom script";/root/docker/setup/05-custom.sh||{ echo "Failed to execute /root/docker/setup/05-custom.sh" >&2 && exit 10; };echo "Done running the custom script";fi; \
if [ -f "/root/docker/setup/05-custom.sh" ];then echo "Running the custom script";/root/docker/setup/05-custom.sh||{ echo "Failed to execute /root/docker/setup/05-custom.sh" && exit 10; };echo "Done running the custom script";fi; \
echo ""
RUN echo "Running final commands before cleanup"; \
@@ -179,7 +186,7 @@ RUN echo "Deleting unneeded files"; \
rm -rf /lib/systemd/system/sockets.target.wants/*udev* || true; \
rm -rf /lib/systemd/system/sockets.target.wants/*initctl* || true; \
rm -Rf /usr/share/doc/* /var/tmp/* /var/cache/*/* /root/.cache/* /usr/share/info/* /tmp/* || true; \
if [ -d "/lib/systemd/system/sysinit.target.wants" ];then cd "/lib/systemd/system/sysinit.target.wants" && rm -f $(ls | grep -v systemd-tmpfiles-setup);fi; \
if [ -d "/lib/systemd/system/sysinit.target.wants" ];then cd "/lib/systemd/system/sysinit.target.wants" && for want_file in *; do [ "$want_file" = "systemd-tmpfiles-setup" ] || rm -f "$want_file"; done; fi; \
if [ -f "/root/docker/setup/07-cleanup.sh" ];then echo "Running the cleanup script";/root/docker/setup/07-cleanup.sh||{ echo "Failed to execute /root/docker/setup/07-cleanup.sh" >&2 && exit 10; };echo "Done running the cleanup script";fi; \
echo ""
@@ -223,8 +230,8 @@ LABEL org.opencontainers.image.authors="${LICENSE}"
LABEL org.opencontainers.image.created="${BUILD_DATE}"
LABEL org.opencontainers.image.version="${BUILD_VERSION}"
LABEL org.opencontainers.image.schema-version="${BUILD_VERSION}"
LABEL org.opencontainers.image.url="https://hub.docker.com/casjaysdevdocker/ollama"
LABEL org.opencontainers.image.source="https://hub.docker.com/casjaysdevdocker/ollama"
LABEL org.opencontainers.image.url="https://docker.io/casjaysdevdocker/ollama"
LABEL org.opencontainers.image.source="https://docker.io/casjaysdevdocker/ollama"
LABEL org.opencontainers.image.vcs-type="Git"
LABEL org.opencontainers.image.revision="${GIT_COMMIT}"
LABEL org.opencontainers.image.source="https://github.com/casjaysdevdocker/ollama"
@@ -260,3 +267,4 @@ STOPSIGNAL SIGRTMIN+3
ENTRYPOINT [ "tini", "-p", "SIGTERM","--", "/usr/local/bin/entrypoint.sh" ]
HEALTHCHECK --start-period=10m --interval=5m --timeout=15s CMD [ "/usr/local/bin/entrypoint.sh", "healthcheck" ]
+8 -614
View File
@@ -1,163 +1,6 @@
## 👋 Welcome to ollama 🚀
ollama README
This Docker container provides **Ollama** with a built-in **Open WebUI** for easy interaction with Large Language Models (LLMs).
**Features:**
- 🤖 Ollama server for running LLMs locally
- 🌐 Open WebUI - Full-featured web interface with authentication
- 📦 Auto-pull models on startup via MODELS environment variable
- 🐳 **Docker Model Runner (DMR) Compatible** - Works alongside Docker's built-in AI service
- ⚡ **CPU Optimized** - OpenBLAS for 3-5x faster CPU inference (8-12 tok/sec for 7B models)
- 🎮 **GPU Support** - NVIDIA (CUDA), AMD (ROCm), automatic detection and fallback
- 💻 **Smart Hardware Detection** - Automatically uses GPU if available, falls back to optimized CPU
- 💾 Persistent data storage for models and configurations
- 🔐 Automatic SSL/TLS support
- 📊 Health monitoring and logging
- 🏗️ Multi-architecture support (amd64, arm64)
**Ports:**
- `11434` - Ollama API server (DMR uses port 12434)
- `64080:80` - Open WebUI interface (host:container)
**Environment Variables:**
**Container/Models:**
- `MODELS` - Comma or space-separated list of models to auto-pull on startup
- **Default**: If not set, automatically pulls `qwen2.5-coder:3b` (optimal for CPU coding)
- Examples:
- `MODELS="llama3.2,mistral"`
- `MODELS="llama3.2 mistral phi"`
- `MODELS="llama3.2,mistral phi"` (mixed delimiters supported)
- The first model in the list will be set as the default
- Models are pulled from Ollama's registry (registry.ollama.ai)
- **Note**: Docker Model Registry (DMR) is not yet natively supported by Ollama
**Ollama Configuration:**
- `OLLAMA_HOST` - IP address and port for Ollama (default: `0.0.0.0:11434`)
- `OLLAMA_MODELS` - Path to models directory (default: `/data/ollama/models`)
- `OLLAMA_KEEP_ALIVE` - Duration models stay loaded in memory (default: `5m`)
- `OLLAMA_MAX_LOADED_MODELS` - Maximum loaded models per GPU (default: `0` = unlimited)
- `OLLAMA_NUM_PARALLEL` - Maximum parallel requests (default: `1`)
- `OLLAMA_MAX_QUEUE` - Maximum queued requests (default: `512`)
- `OLLAMA_CONTEXT_LENGTH` - Default context length (default: `4096`)
- `OLLAMA_DEBUG` - Enable debug logging (set to `1` to enable)
- `OLLAMA_ORIGINS` - Allowed CORS origins (default: `*`)
- `OLLAMA_FLASH_ATTENTION` - Enable flash attention (set to `1`)
- `OLLAMA_GPU_OVERHEAD` - Reserve VRAM per GPU in bytes
**Open WebUI Configuration:**
- `WEBUI_URL` - URL where Open WebUI is accessible (default: `http://localhost:64080`)
- `WEBUI_NAME` - Custom name for the WebUI (default: `Open WebUI`)
- `WEBUI_SECRET_KEY` - Secret key for sessions (auto-generated if not set)
- `ENABLE_SIGNUP` - Allow new user registrations (default: `true`)
- `DEFAULT_USER_ROLE` - Role for new users: `pending`, `user`, or `admin` (default: `pending`)
- `DEFAULT_MODELS` - Comma-separated default model IDs
- `OLLAMA_BASE_URL` - Ollama API URL (default: `http://127.0.0.1:11434`)
- `ENABLE_ADMIN_EXPORT` - Allow admins to export data (default: `true`)
**GPU-Specific:**
- `CUDA_VISIBLE_DEVICES` - Which NVIDIA GPUs to use
- `HIP_VISIBLE_DEVICES` - Which AMD GPUs to use (numeric ID)
- `ROCR_VISIBLE_DEVICES` - Which AMD GPUs to use (UUID or ID)
- `HSA_OVERRIDE_GFX_VERSION` - Override AMD GPU GFX version
**CPU Optimization:**
- `OLLAMA_NUM_THREADS` - CPU cores for inference (default: auto-detect, uses all cores)
- `OPENBLAS_NUM_THREADS` - Override OpenBLAS threads (default: matches OLLAMA_NUM_THREADS)
- `OMP_NUM_THREADS` - Override OpenMP threads (default: matches OLLAMA_NUM_THREADS)
**Performance Tuning:**
Recommended settings for different hardware:
**CPU-only (4-core/16GB):**
```bash
-e OLLAMA_NUM_PARALLEL=2 \
-e OLLAMA_MAX_LOADED_MODELS=1 \
-e MODELS="qwen2.5-coder:3b" # Expected: 10-20 tok/sec
```
**CPU-only (8-core/32GB):**
```bash
-e OLLAMA_NUM_PARALLEL=4 \
-e OLLAMA_MAX_LOADED_MODELS=1 \
-e MODELS="qwen2.5:7b" # Expected: 8-12 tok/sec with OpenBLAS
```
**GPU (any size):**
```bash
--gpus all \
-e OLLAMA_NUM_PARALLEL=4 \
-e OLLAMA_MAX_LOADED_MODELS=0 \
-e MODELS="llama3.2:70b" # Expected: 50-150+ tok/sec
```
**Hardware Acceleration:**
This container includes **automatic hardware detection** and optimization:
**✅ CPU Optimizations (Built-in):**
- **OpenBLAS**: Optimized BLAS library for 3-5x faster matrix operations
- **Multi-threading**: Automatically configures for available CPU cores
- **Expected Performance**:
- 7B models (qwen2.5:7b): 8-12 tokens/sec on 8-core CPU
- 3B models (qwen2.5-coder:3b): 10-20 tokens/sec on 4-core CPU
- 1.5B models: 20-40 tokens/sec on 4-core CPU
**🎮 GPU Support (Automatic Detection):**
- **NVIDIA GPUs**: ✅ Full CUDA support (production ready)
- Performance: 50-150+ tokens/sec (7B models)
- Requirement: nvidia-container-toolkit on host
- Flag: `--gpus all`
- **AMD GPUs**: ✅ Full ROCm support (production ready)
- Performance: 40-120+ tokens/sec (7B models)
- Requirement: ROCm 5.x+ drivers on host
- Flags: `--device=/dev/kfd --device=/dev/dri`
- **Intel GPUs**: ⚠️ Experimental/Limited support
- Performance: Variable (10-60 tokens/sec, often slower than CPU)
- Works: Arc GPUs (experimental), iGPUs (limited)
- Flag: `--device=/dev/dri`
- Note: CPU mode often faster for integrated GPUs
- **Automatic Fallback**: Uses optimized CPU when no GPU detected
**Container automatically:**
- ✅ Detects available GPU at startup
- ✅ Uses GPU if available (100+ tok/sec for 7B models)
- ✅ Falls back to optimized CPU if no GPU (8-12 tok/sec for 7B models)
- ✅ Configures threads based on available CPU cores
- ✅ Sets optimal BLAS library parameters
**To enable GPU access:**
```bash
# NVIDIA GPU (requires nvidia-container-toolkit on host)
# ✅ RECOMMENDED - Best performance
docker run -d --gpus all -p 11434:11434 -p 64080:80 casjaysdevdocker/ollama
# AMD GPU (requires ROCm 5.x+ drivers)
# ✅ RECOMMENDED - Good performance
docker run -d --device=/dev/kfd --device=/dev/dri -p 11434:11434 -p 64080:80 casjaysdevdocker/ollama
# Intel GPU (Arc or integrated)
# ⚠️ EXPERIMENTAL - May not work, CPU often faster
docker run -d --device=/dev/dri -p 11434:11434 -p 64080:80 casjaysdevdocker/ollama
# CPU-only (no flags needed - automatically optimized)
# ✅ RECOMMENDED - Reliable 8-12 tok/sec with OpenBLAS
docker run -d -p 11434:11434 -p 64080:80 casjaysdevdocker/ollama
```
**GPU Performance Expectations:**
- **NVIDIA**: 50-150+ tok/sec (7B), 30-60 tok/sec (13B), 10-30 tok/sec (70B)
- **AMD**: 40-120+ tok/sec (7B), 25-50 tok/sec (13B), 8-25 tok/sec (70B)
- **Intel**: 10-60 tok/sec (highly variable, experimental)
- **CPU (Optimized)**: 8-12 tok/sec (7B), 5-8 tok/sec (13B)
**Note**: No GPU drivers/libraries are installed in the container. GPU access works via runtime device passthrough from the host system. This keeps the image lightweight (10.2GB) while supporting NVIDIA and AMD GPUs. Intel GPU support is experimental and not officially supported by Ollama.
ollama README
## Install my system scripts
@@ -176,12 +19,10 @@ dockermgr update ollama
## Install and run container
```shell
dockerHome="/var/lib/srv/$USER/docker/casjaysdevdocker/ollama/ollama/latest/volumes"
mkdir -p "/var/lib/srv/$USER/docker/ollama/volumes"
dockerHome="/var/lib/srv/$USER/docker/casjaysdevdocker/ollama/ollama/latest/rootfs"
mkdir -p "/var/lib/srv/$USER/docker/ollama/rootfs"
git clone "https://github.com/dockermgr/ollama" "$HOME/.local/share/CasjaysDev/dockermgr/ollama"
cp -Rfva "$HOME/.local/share/CasjaysDev/dockermgr/ollama/rootfs/." "$dockerHome/"
# Simple start - uses default model (qwen2.5-coder:3b, optimal for CPU)
docker run -d \
--restart always \
--privileged \
@@ -190,474 +31,27 @@ docker run -d \
-e TZ=${TIMEZONE:-America/New_York} \
-v "$dockerHome/data:/data:z" \
-v "$dockerHome/config:/config:z" \
-p 11434:11434 \
-p 64080:80 \
casjaysdevdocker/ollama:latest
# For CPU-only with custom models
docker run -d \
--restart always \
--privileged \
--name casjaysdevdocker-ollama-latest \
--hostname ollama \
-e TZ=${TIMEZONE:-America/New_York} \
-e MODELS="llama3.2,mistral" \
-v "$dockerHome/data:/data:z" \
-v "$dockerHome/config:/config:z" \
-p 11434:11434 \
-p 64080:80 \
casjaysdevdocker/ollama:latest
# For NVIDIA GPU with auto-pull models
docker run -d \
--restart always \
--privileged \
--gpus all \
--name casjaysdevdocker-ollama-latest \
--hostname ollama \
-e TZ=${TIMEZONE:-America/New_York} \
-e MODELS="llama3.2 mistral phi" \
-v "$dockerHome/data:/data:z" \
-v "$dockerHome/config:/config:z" \
-p 11434:11434 \
-p 64080:80 \
casjaysdevdocker/ollama:latest
# For AMD GPU
docker run -d \
--restart always \
--privileged \
--device=/dev/kfd \
--device=/dev/dri \
--name casjaysdevdocker-ollama-latest \
--hostname ollama \
-e TZ=${TIMEZONE:-America/New_York} \
-e MODELS="llama3.2,mistral,phi" \
-v "$dockerHome/data:/data:z" \
-v "$dockerHome/config:/config:z" \
-p 11434:11434 \
-p 64080:80 \
-p 80:80 \
casjaysdevdocker/ollama:latest
```
---
## 🔌 IDE & Client Integration
Once the container is running, you can connect various IDEs, editors, and applications to use Ollama's API.
### 📝 VSCode Extensions
#### **Continue.dev** - AI Code Assistant
1. Install the [Continue extension](https://marketplace.visualstudio.com/items?itemName=Continue.continue)
2. Open VSCode Settings (Ctrl/Cmd+Shift+P → "Continue: Open config.json")
3. Add configuration:
```json
{
"models": [
{
"title": "Ollama Llama3.2",
"provider": "ollama",
"model": "llama3.2",
"apiBase": "http://localhost:11434"
}
]
}
```
#### **Cody** - AI Code Assistant by Sourcegraph
1. Install [Cody extension](https://marketplace.visualstudio.com/items?itemName=sourcegraph.cody-ai)
2. Open Settings → Extensions → Cody
3. Configure:
```json
{
"cody.experimental.ollamaModels": ["llama3.2", "mistral"],
"cody.experimental.ollamaEndpoint": "http://localhost:11434"
}
```
#### **Ollama Autocoder**
1. Install [Ollama Autocoder](https://marketplace.visualstudio.com/items?itemName=Ollama.ollama-autocoder)
2. Settings → Extensions → Ollama Autocoder
3. Set API URL: `http://localhost:11434`
#### **Twinny** - AI Code Assistant
1. Install [Twinny extension](https://marketplace.visualstudio.com/items?itemName=rjmacarthy.twinny)
2. Configure in settings:
```json
{
"twinny.ollamaApiUrl": "http://localhost:11434",
"twinny.ollamaModel": "llama3.2"
}
```
---
### 🖥️ IDE Applications
#### **Cursor** - AI-First Code Editor
1. Open Cursor → Settings → Models
2. Select "OpenAI Compatible"
3. Configure:
- **Base URL**: `http://localhost:11434/v1`
- **API Key**: `ollama` (or leave empty)
- **Model**: `llama3.2`
#### **Claude Code / Windsurf**
1. Open Settings → AI Provider
2. Select "Custom OpenAI Compatible"
3. Configure:
- **Endpoint**: `http://localhost:11434/v1/chat/completions`
- **Model**: `llama3.2`
- **API Key**: Not required
#### **JetBrains IDEs** (IntelliJ, PyCharm, etc.)
1. Install [Ollama plugin](https://plugins.jetbrains.com/plugin/22433-ollama)
2. Settings → Tools → Ollama
3. Set Server URL: `http://localhost:11434`
---
### 🌐 Desktop Applications
#### **Open WebUI** (Built-in)
- **URL**: `http://localhost:64080`
- Full-featured web interface with authentication
- Supports chat, model management, RAG, and more
#### **Ollama Desktop Client**
- Connect to: `http://localhost:11434`
- Native desktop experience for model management
#### **Jan** - ChatGPT Alternative
1. Download [Jan](https://jan.ai/)
2. Settings → Advanced → OpenAI Compatible
3. Set Base URL: `http://localhost:11434/v1`
#### **Enchanted** (macOS/iOS)
1. Download from App Store
2. Settings → Ollama Server
3. Set URL: `http://localhost:11434`
---
### 🔧 API Integration
#### **OpenAI-Compatible Endpoints**
Ollama provides OpenAI-compatible API endpoints:
```bash
# Chat Completions (OpenAI compatible)
curl http://localhost:11434/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "llama3.2",
"messages": [{"role": "user", "content": "Hello!"}]
}'
# Completions
curl http://localhost:11434/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "llama3.2",
"prompt": "Tell me a joke"
}'
# List Models
curl http://localhost:11434/v1/models
```
#### **Native Ollama API**
```bash
# Generate
curl http://localhost:11434/api/generate -d '{
"model": "llama3.2",
"prompt": "Why is the sky blue?",
"stream": false
}'
# Chat
curl http://localhost:11434/api/chat -d '{
"model": "llama3.2",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": false
}'
# List Models
curl http://localhost:11434/api/tags
```
---
### 🐍 Python Integration
```python
# Using OpenAI Python SDK
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:11434/v1",
api_key="ollama" # Not required but SDK needs something
)
response = client.chat.completions.create(
model="llama3.2",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
```
```python
# Using Ollama Python Library
import ollama
response = ollama.chat(
model='llama3.2',
messages=[{'role': 'user', 'content': 'Hello!'}]
)
print(response['message']['content'])
```
---
### 🦀 Rust Integration
```toml
# Cargo.toml
[dependencies]
ollama-rs = "0.2"
```
```rust
use ollama_rs::Ollama;
#[tokio::main]
async fn main() {
let ollama = Ollama::new("http://localhost".to_string(), 11434);
let response = ollama.generate("llama3.2", "Why is the sky blue?").await;
println!("{}", response.unwrap());
}
```
---
### 🟦 JavaScript/TypeScript Integration
```bash
npm install ollama
```
```javascript
import { Ollama } from 'ollama'
const ollama = new Ollama({ host: 'http://localhost:11434' })
const response = await ollama.chat({
model: 'llama3.2',
messages: [{ role: 'user', content: 'Hello!' }],
})
console.log(response.message.content)
```
---
### 🔐 CORS Configuration
The container is configured with `OLLAMA_ORIGINS="*"` by default, allowing all origins. To restrict access:
```bash
docker run -d \
-e OLLAMA_ORIGINS="http://localhost:3000,https://myapp.com" \
-p 11434:11434 -p 64080:80 \
casjaysdevdocker/ollama:latest
```
---
### 🚀 Quick Test
Verify the API is working:
```bash
# Check version
curl http://localhost:11434/api/version
# Test chat (requires a model pulled first)
curl http://localhost:11434/api/chat -d '{
"model": "llama3.2",
"messages": [{"role": "user", "content": "Hello"}],
"stream": false
}'
```
---
## 📦 Docker Model Runner (DMR) Integration
### ✅ Compatible with Docker Model Runner
Docker Model Runner is Docker's built-in AI service that runs models directly within Docker Desktop/Engine. It provides **Ollama-compatible APIs** on port **12434**.
**This container (port 11434) and DMR (port 12434) can work side-by-side:**
```bash
# DMR runs on port 12434 (Docker's built-in)
curl http://localhost:12434/api/tags
# This Ollama container runs on port 11434
curl http://localhost:11434/api/tags
```
### When to Use Each
| Feature | This Container (Ollama) | Docker Model Runner (DMR) |
|---------|------------------------|---------------------------|
| **Port** | 11434 | 12434 |
| **Built-in WebUI** | ✅ Open WebUI on 64080 | ❌ (use external tools) |
| **Auto-pull models** | ✅ Via MODELS env var | ✅ Via docker model pull |
| **Model storage** | /data/ollama/models | Docker-managed |
| **GPU support** | ✅ NVIDIA/AMD/Intel | ✅ NVIDIA (vLLM/Diffusers) |
| **Inference engines** | Ollama default | llama.cpp, vLLM, Diffusers |
| **Requires** | Docker container | Docker Desktop 4.40+ |
| **API compatibility** | Ollama, OpenAI (v1) | Ollama, OpenAI, Anthropic |
### Using Both Together
**Scenario 1: DMR for quick testing, Container for production**
```bash
# Quick test with DMR (no container needed)
docker model pull ai/llama3.2
curl http://localhost:12434/api/chat -d '{...}'
# Production with full WebUI and auto-pull
docker run -d -e MODELS="llama3.2" -p 11434:11434 -p 64080:80 casjaysdevdocker/ollama
```
**Scenario 2: IDE points to container, DMR for experiments**
```json
// VSCode Continue extension → this container
{
"models": [{
"apiBase": "http://localhost:11434"
}]
}
```
**Scenario 3: Open WebUI connects to DMR instead**
```bash
# Run this container but point WebUI to DMR
docker run -d \
-e OLLAMA_BASE_URL="http://172.17.0.1:12434" \
-p 64080:80 \
casjaysdevdocker/ollama
```
### Docker Model Runner Commands
```bash
# Enable DMR in Docker Desktop
docker desktop enable model-runner --tcp 12434
# Pull models via DMR
docker model pull ai/llama3.2
docker model pull ai/mistral
# List DMR models
docker model ls
# Chat with DMR (Ollama-compatible API)
curl http://localhost:12434/api/chat -d '{
"model": "ai/llama3.2",
"messages": [{"role": "user", "content": "Hello"}]
}'
# Use OpenAI-compatible endpoint
curl http://localhost:12434/engines/v1/chat/completions -d '{
"model": "ai/llama3.2",
"messages": [{"role": "user", "content": "Hello"}]
}'
```
### IDE Configuration for DMR
**Continue.dev with DMR:**
```json
{
"models": [{
"title": "DMR Llama3.2",
"provider": "ollama",
"model": "ai/llama3.2",
"apiBase": "http://localhost:12434"
}]
}
```
**Cursor with DMR:**
- Base URL: `http://localhost:12434/engines/v1`
- Model: `ai/llama3.2`
### Model Registry Differences
**Ollama Registry (This Container):**
- Models from: `registry.ollama.ai`
- Format: `llama3.2`, `mistral`, `phi`
- Pull via: `ollama pull` or MODELS env var
**Docker Model Runner (DMR):**
- Models from: Docker Hub (`hub.docker.com/u/ai`)
- Format: `ai/llama3.2`, `ai/mistral`, `ai/qwen2.5-coder`
- Pull via: `docker model pull`
- Supports OCI artifacts
### Benefits of Using Both
1. **DMR**: Quick model testing without container overhead
2. **This Container**: Full-featured deployment with WebUI, authentication, auto-pull
3. **Flexibility**: Switch between them via port configuration
4. **Integration**: Use DMR for CI/CD, container for production apps
### Requirements
**Docker Model Runner:**
- Docker Desktop 4.40+ (macOS) or 4.41+ (Windows)
- Docker Engine with DMR plugin
- Enable via: Settings → Features → Enable Docker Model Runner
**This Container:**
- Standard Docker (no version requirements)
- Works anywhere Docker runs
---
## via docker-compose
```yaml
version: "2"
services:
ollama:
ProjectName:
image: casjaysdevdocker/ollama
container_name: casjaysdevdocker-ollama
environment:
- TZ=America/New_York
- HOSTNAME=ollama
- MODELS=llama3.2,mistral,phi
volumes:
- "/var/lib/srv/$USER/docker/casjaysdevdocker/ollama/ollama/latest/volumes/data:/data:z"
- "/var/lib/srv/$USER/docker/casjaysdevdocker/ollama/ollama/latest/volumes/config:/config:z"
- "/var/lib/srv/$USER/docker/casjaysdevdocker/ollama/ollama/latest/rootfs/data:/data:z"
- "/var/lib/srv/$USER/docker/casjaysdevdocker/ollama/ollama/latest/rootfs/config:/config:z"
ports:
- 11434:11434
- 64080:80
- 80:80
restart: always
# For NVIDIA GPU, uncomment:
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: all
# capabilities: [gpu]
```
## Get source files
+33 -68
View File
@@ -1,13 +1,13 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202512161441-git
##@Version : 202602061352-git
# @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.pro
# @@License : WTFPL
# @@ReadME : entrypoint.sh --help
# @@Copyright : Copyright: (c) 2026 Jason Hempstead, Casjays Developments
# @@Created : Wednesday, Jan 28, 2026 23:19 EST
# @@Created : Tuesday, May 05, 2026 14:38 EDT
# @@File : entrypoint.sh
# @@Description : Entrypoint file for ollama
# @@Changelog : New script
@@ -21,56 +21,22 @@
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# run trap command on exit
trap '__trap_exit_handler' EXIT
trap '__trap_signal_handler' INT TERM PWR
# - - - - - - - - - - - - - - - - - - - - - - - - -
__trap_exit_handler() {
local retVal=$?
if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then
rm -Rf "$SERVICE_PID_FILE" 2>/dev/null || true
fi
exit $retVal
}
# - - - - - - - - - - - - - - - - - - - - - - - - -
__trap_signal_handler() {
local retVal=$?
echo "Container received shutdown signal"
if [ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ]; then
rm -Rf "$SERVICE_PID_FILE" 2>/dev/null || true
fi
exit $retVal
}
trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' INT TERM PWR
# - - - - - - - - - - - - - - - - - - - - - - - - -
# setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
if [ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ]; then
export DEBUGGER_OPTIONS="$(<"/config/.debug")"
else
DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
fi
if [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; then
echo "Enabling debugging"
set -o pipefail -x$DEBUGGER_OPTIONS
export DEBUGGER="on"
else
set -o pipefail
fi
[ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
{ [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; } && echo "Enabling debugging" && set -o pipefail -x$DEBUGGER_OPTIONS && export DEBUGGER="on" || set -o pipefail
# - - - - - - - - - - - - - - - - - - - - - - - - -
PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options
SCRIPT_FILE="$0"
CONTAINER_NAME="ollama"
SCRIPT_NAME="$(basename -- "$SCRIPT_FILE" 2>/dev/null)"
SCRIPT_NAME="${SCRIPT_FILE##*/}"
CONTAINER_NAME="${ENV_CONTAINER_NAME:-$CONTAINER_NAME}"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# remove whitespaces from beginning argument
while :; do
if [ "$1" = " " ]; then
shift 1
else
break
fi
done
while :; do [ "$1" = " " ] && shift 1 || break; done
# - - - - - - - - - - - - - - - - - - - - - - - - -
[ "$1" = "$SCRIPT_FILE" ] && shift 1
[ "$1" = "$SCRIPT_NAME" ] && shift 1
@@ -204,7 +170,7 @@ export ENTRYPOINT_DATA_INIT_FILE="${ENTRYPOINT_DATA_INIT_FILE:-/data/.docker_has
export ENTRYPOINT_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}"
# - - - - - - - - - - - - - - - - - - - - - - - - -
if [ -n "$CONTAINER_WEB_SERVER_WWW_REPO" ]; then
www_temp_dir="/tmp/git/$(basename -- "$CONTAINER_WEB_SERVER_WWW_REPO")"
www_temp_dir="/tmp/git/${CONTAINER_WEB_SERVER_WWW_REPO##*/}"
rm -Rf "${WWW_ROOT_DIR:?}"/* "${www_temp_dir:?}"/* 2>/dev/null || true
mkdir -p "$WWW_ROOT_DIR" "$www_temp_dir" 2>/dev/null || true
git clone -q "$CONTAINER_WEB_SERVER_WWW_REPO" "$www_temp_dir" 2>/dev/null || true
@@ -401,7 +367,7 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
# - - - - - - - - - - - - - - - - - - - - - - - - -
# import hosts file into container
if [ -f "/usr/local/etc/hosts" ] && [ "$UPDATE_FILE_HOSTS" = "yes" ]; then
cat "/usr/local/etc/hosts" 2>/dev/null | grep -vF "$HOSTNAME" >>"/etc/hosts" 2>/dev/null || true
grep -vF "$HOSTNAME" "/usr/local/etc/hosts" 2>/dev/null >>"/etc/hosts" 2>/dev/null || true
fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
# import resolv.conf file into container
@@ -475,26 +441,30 @@ fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
# if no pid assume container restart - clean stale files on restart
if [ -f "$ENTRYPOINT_PID_FILE" ]; then
START_SERVICES="no"
touch "$ENTRYPOINT_PID_FILE"
# Check if the PID in the file is still running
entrypoint_pid=$(cat "$ENTRYPOINT_PID_FILE" 2>/dev/null || echo "")
if [ -n "$entrypoint_pid" ] && kill -0 "$entrypoint_pid" 2>/dev/null; then
# Process is still running, don't restart services
START_SERVICES="no"
touch "$ENTRYPOINT_PID_FILE"
else
# PID file exists but process is dead - this is a restart
START_SERVICES="yes"
# Clean any stale PID files on restart
rm -f /run/__start_init_scripts.pid /run/init.d/*.pid /run/*.pid 2>/dev/null || true
fi
else
START_SERVICES=yes
# Clean any stale PID files on first run
rm -f /run/.start_init_scripts.pid /run/init.d/*.pid /run/*.pid 2>/dev/null || true
rm -f /run/__start_init_scripts.pid /run/init.d/*.pid /run/*.pid 2>/dev/null || true
fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
if [ "$ENTRYPOINT_MESSAGE" = "yes" ]; then
__printf_space "40" "The containers ip address is:" "$CONTAINER_IP4_ADDRESS"
fi
[ "$ENTRYPOINT_MESSAGE" = "yes" ] && __printf_space "40" "The containers ip address is:" "$CONTAINER_IP4_ADDRESS"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Show configured listing processes
if [ "$ENTRYPOINT_MESSAGE" = "yes" ] && [ -n "$ENV_PORTS" ]; then
show_port=""
for port in $ENV_PORTS; do
if [ -n "$port" ]; then
show_port+="$(printf '%s ' "${port// /}") "
fi
done
for port in $ENV_PORTS; do [ -n "$port" ] && show_port+="$(printf '%s ' "${port// /}") "; done
__printf_space "40" "The following ports are open:" "$show_port"
unset port show_port
fi
@@ -529,6 +499,9 @@ if [ "$START_SERVICES" = "yes" ] || [ -z "$1" ]; then
echo "$$" >"$ENTRYPOINT_PID_FILE"
__start_init_scripts "/usr/local/etc/docker/init.d"
CONTAINER_INIT="${CONTAINER_INIT:-no}"
# Services started successfully - enter monitoring mode
__no_exit
exit $?
fi
START_SERVICES="no"
fi
@@ -538,7 +511,7 @@ export START_SERVICES CONTAINER_INIT ENTRYPOINT_PID_FILE
case "$1" in
init)
shift 1
echo "Container has been Initialized"
__log_info "Container has been initialized"
exit 0
;;
tail)
@@ -569,7 +542,7 @@ logs)
clean)
log_files="$(find "/data/logs" -type f)"
for log in "${log_files[@]}"; do
echo "clearing $log"
__log_info "Clearing log file: $log"
printf '' >$log
done
;;
@@ -582,7 +555,7 @@ logs)
cron)
shift 1
__cron "$@" &
echo "cron script is running with pid: $!"
__log_info "Cron script is running with PID: $!"
exit
;;
# backup data and config dirs
@@ -610,7 +583,7 @@ healthcheck)
[ "$healthEnabled" = "yes" ] || exit 0
if [ -d "/run/healthcheck" ] && [ "$(ls -A "/run/healthcheck" | wc -l)" -ne 0 ]; then
for service in /run/healthcheck/*; do
name=$(basename -- $service)
name="${service##*/}"
services+="$name "
done
fi
@@ -698,11 +671,7 @@ start)
export PATH="/usr/local/etc/docker/init.d:$PATH"
if [ $# -eq 0 ]; then
scripts="$(ls -A "/usr/local/etc/docker/init.d")"
if [ -n "$scripts" ]; then
echo "$scripts"
else
echo "No scripts found in: /usr/local/etc/docker/init.d"
fi
[ -n "$scripts" ] && echo "$scripts" || echo "No scripts found in: /usr/local/etc/docker/init.d"
exit
elif [ "$1" = "all" ]; then
shift $#
@@ -721,11 +690,7 @@ start)
if [ $# -eq 0 ]; then
if [ ! -f "$ENTRYPOINT_PID_FILE" ]; then
echo "$$" >"$ENTRYPOINT_PID_FILE"
if [ "$START_SERVICES" = "no" ] && [ "$CONTAINER_INIT" = "yes" ]; then
:
else
__start_init_scripts "/usr/local/etc/docker/init.d"
fi
[ "$START_SERVICES" = "no" ] && [ "$CONTAINER_INIT" = "yes" ] || __start_init_scripts "/usr/local/etc/docker/init.d"
fi
__no_exit
else
+2 -1
View File
@@ -103,7 +103,7 @@ install)
[ -n "$1" ] || exit 0
[ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_install_cmd="sudo $pkmgr_install_cmd"
if [ -f "$1" ]; then
install_list="$(cat "$1")"
install_list="$(tr '\n' ' ' < "$1")"
else
install_list="$*"
fi
@@ -140,3 +140,4 @@ clean)
esac
# - - - - - - - - - - - - - - - - - - - - - - - - -
# end