[PR #8383] fix: run container as non-root user #12698

Open
opened 2026-04-13 00:07:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/8383
Author: @chaturvedi-kna
Created: 1/11/2025
Status: 🔄 Open

Base: mainHead: rootless-container-support


📝 Commits (2)

  • d2ba011 fix: add rootless container support
  • 074d639 Merge branch 'main' into rootless-container-support

📊 Changes

1 file changed (+8 additions, -0 deletions)

View changed files

📝 Dockerfile (+8 -0)

📄 Description

Enable non-root user Container Deployment Support

Description

This PR adds support for running ollama in rootless containers by properly setting up permissions for the .ollama directory. This change enables ollama to run in environments that enforce non-root execution such as:

  • OpenShift
  • Kubernetes with strict security contexts
  • Containers with user namespace remapping

Changes

  • Added directory creation and permission setup in the final stage of Dockerfile
  • Set container to run as non-root user (UID 1001)
  • Configured group permissions to support random GID assignment

Testing Done

  • Built image with podman
  • Deployed on OpenShift
  • Verified container starts successfully with non-root user
  • Confirmed .ollama directory is properly accessible

Previous Behavior

The container would fail to start in rootless environments with the error:

Couldn't find '/.ollama/id_ed25519'. Generating new private key.
Error: could not create directory mkdir /.ollama: permission denied

New Behavior

  • Container starts successfully as non-root user
  • .ollama directory is created with proper permissions

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/8383 **Author:** [@chaturvedi-kna](https://github.com/chaturvedi-kna) **Created:** 1/11/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `rootless-container-support` --- ### 📝 Commits (2) - [`d2ba011`](https://github.com/ollama/ollama/commit/d2ba0116bf93e06b3df51baf760ba5311b2992e4) fix: add rootless container support - [`074d639`](https://github.com/ollama/ollama/commit/074d639b5211a0c31f012d2308e249f5ae0074cd) Merge branch 'main' into rootless-container-support ### 📊 Changes **1 file changed** (+8 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `Dockerfile` (+8 -0) </details> ### 📄 Description **Enable non-root user Container Deployment Support** **Description** This PR adds support for running ollama in rootless containers by properly setting up permissions for the `.ollama` directory. This change enables ollama to run in environments that enforce non-root execution such as: * OpenShift * Kubernetes with strict security contexts * Containers with user namespace remapping **Changes** * Added directory creation and permission setup in the final stage of Dockerfile * Set container to run as non-root user (UID 1001) * Configured group permissions to support random GID assignment **Testing Done** * Built image with podman * Deployed on OpenShift * Verified container starts successfully with non-root user * Confirmed `.ollama` directory is properly accessible **Previous Behavior** The container would fail to start in rootless environments with the error: ``` Couldn't find '/.ollama/id_ed25519'. Generating new private key. Error: could not create directory mkdir /.ollama: permission denied ``` **New Behavior** * Container starts successfully as non-root user * `.ollama` directory is created with proper permissions --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 00:07:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#12698