[GH-ISSUE #6543] Failed to start docker without root access #50627

Closed
opened 2026-04-28 16:37:35 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @leobenkel on GitHub (Aug 28, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6543

What is the issue?

So I am trying to extend the base ollama image to have a container with a shared storage that is not with root permission.

That way i can pull images, and have the raw file available in a shared folder.

After messing around for a while, i am still stuck there:

Couldn't find '/home/ollama/.ollama/id_ed25519'. Generating new private key.
Error: open /home/ollama/.ollama/id_ed25519: permission denied

No matter what I do the .ollama folder is owned by root

The relevant section of my Dockerfile:

ARG LLM_ENGINE_VERSION
ARG OS_PLATFORM
FROM --platform=${OS_PLATFORM} ollama/ollama:${LLM_ENGINE_VERSION}

# ...

RUN apt-get update && apt-get install -y curl bash

ARG USER_ID
ARG GROUP_ID

ENV OLLAMA_HOST=0.0.0.0
ENV OLLAMA_MAX_LOADED_MODELS=2
ENV OLLAMA_NUM_PARALLEL=3
ENV OLLAMA_NOHISTORY=1

EXPOSE 11434
# ENV OLLAMA_MODELS=/home/ollama/.ollama/models
# ENV OLLAMA_TMPDIR=/home/ollama/.ollama/tmp

ENV USER=ollama
RUN groupadd -r -g $GROUP_ID ollama && useradd --create-home --shell /bin/bash --uid $USER_ID -g ollama ollama


RUN mkdir -p /home/ollama/.ollama && touch /home/ollama/.ollama/.keep
RUN chown -R $USER_ID:$GROUP_ID /home/ollama/ /home/ollama/.ollama

USER $USER_ID:$GROUP_ID

ENTRYPOINT ["/bin/ollama"]
CMD ["serve"]

OS

Docker

GPU

Other

CPU

AMD

Ollama version

0.3.8

Originally created by @leobenkel on GitHub (Aug 28, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6543 ### What is the issue? So I am trying to extend the base ollama image to have a container with a shared storage that is not with root permission. That way i can pull images, and have the raw file available in a shared folder. After messing around for a while, i am still stuck there: ``` Couldn't find '/home/ollama/.ollama/id_ed25519'. Generating new private key. Error: open /home/ollama/.ollama/id_ed25519: permission denied ``` No matter what I do the `.ollama` folder is owned by `root` The relevant section of my `Dockerfile`: ``` ARG LLM_ENGINE_VERSION ARG OS_PLATFORM FROM --platform=${OS_PLATFORM} ollama/ollama:${LLM_ENGINE_VERSION} # ... RUN apt-get update && apt-get install -y curl bash ARG USER_ID ARG GROUP_ID ENV OLLAMA_HOST=0.0.0.0 ENV OLLAMA_MAX_LOADED_MODELS=2 ENV OLLAMA_NUM_PARALLEL=3 ENV OLLAMA_NOHISTORY=1 EXPOSE 11434 # ENV OLLAMA_MODELS=/home/ollama/.ollama/models # ENV OLLAMA_TMPDIR=/home/ollama/.ollama/tmp ENV USER=ollama RUN groupadd -r -g $GROUP_ID ollama && useradd --create-home --shell /bin/bash --uid $USER_ID -g ollama ollama RUN mkdir -p /home/ollama/.ollama && touch /home/ollama/.ollama/.keep RUN chown -R $USER_ID:$GROUP_ID /home/ollama/ /home/ollama/.ollama USER $USER_ID:$GROUP_ID ENTRYPOINT ["/bin/ollama"] CMD ["serve"] ``` ### OS Docker ### GPU Other ### CPU AMD ### Ollama version 0.3.8
GiteaMirror added the dockerfeature request labels 2026-04-28 16:37:36 -05:00
Author
Owner

@rick-github commented on GitHub (Aug 28, 2024):

All the groupadd, mkdir, chown etc happen inside the container. When you run the container, you specify the mount point, and docker binds the host path to the container path. If the host path doesn't exist, docker creates it, hence it's owned by root. If you create the host path before hand, it will retain ownership and mode.

<!-- gh-comment-id:2315933431 --> @rick-github commented on GitHub (Aug 28, 2024): All the `groupadd`, `mkdir`, `chown` etc happen inside the container. When you run the container, you specify the mount point, and docker binds the host path to the container path. If the host path doesn't exist, docker creates it, hence it's owned by root. If you create the host path before hand, it will retain ownership and mode.
Author
Owner

@leobenkel commented on GitHub (Aug 28, 2024):

hmm ok, thanks. ill give it a try

<!-- gh-comment-id:2315959654 --> @leobenkel commented on GitHub (Aug 28, 2024): hmm ok, thanks. ill give it a try
Author
Owner

@dhiltgen commented on GitHub (Oct 24, 2024):

I think this is basically a dup of #5986

<!-- gh-comment-id:2434179526 --> @dhiltgen commented on GitHub (Oct 24, 2024): I think this is basically a dup of #5986
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#50627