Add Ability to run rootless Docker Container with custom UID and GUID #1616

Closed
opened 2025-11-11 14:48:24 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @wggcch on GitHub (Jul 26, 2024).

Is your feature request related to a problem? Please describe.
When mounting the document volume for document scan, the documents and folders are owned by root. This can be problematic when I want to delete scanned documents within the Docker volume itself. Having root ownership restricts the ability to manage these files easily and can lead to permission issues.

Describe the solution you'd like
I would suggest running the Docker container with a custom User ID and Group ID. By specifying a non-root user, it will ensure that the files and folders created within the volume are owned by this user, thus avoiding permission issues and making it easier to manage the scanned documents directly from the host.

Additional context
To implement this feature, the Dockerfile should be modified to accept custom User ID and Group ID as build arguments, and the container should run with these IDs. Additionally, the Docker run command or script should be adjusted to use these custom IDs. This will improve security and ease of file management within the mounted volume.

Example Dockerfile changes:

ARG USER_ID=1001
ARG GROUP_ID=1001

RUN groupadd -g ${GROUP_ID} custom_user && \
    useradd -m -u ${USER_ID} -g ${GROUP_ID} custom_user

USER custom_user

Implementing this feature will greatly enhance the usability and security of the Docker setup for document scanning processes. Thank you for considering this request.

Originally created by @wggcch on GitHub (Jul 26, 2024). **Is your feature request related to a problem? Please describe.** When mounting the document volume for document scan, the documents and folders are owned by root. This can be problematic when I want to delete scanned documents within the Docker volume itself. Having root ownership restricts the ability to manage these files easily and can lead to permission issues. **Describe the solution you'd like** I would suggest running the Docker container with a custom User ID and Group ID. By specifying a non-root user, it will ensure that the files and folders created within the volume are owned by this user, thus avoiding permission issues and making it easier to manage the scanned documents directly from the host. **Additional context** To implement this feature, the Dockerfile should be modified to accept custom User ID and Group ID as build arguments, and the container should run with these IDs. Additionally, the Docker run command or script should be adjusted to use these custom IDs. This will improve security and ease of file management within the mounted volume. Example Dockerfile changes: ```dockerfile ARG USER_ID=1001 ARG GROUP_ID=1001 RUN groupadd -g ${GROUP_ID} custom_user && \ useradd -m -u ${USER_ID} -g ${GROUP_ID} custom_user USER custom_user ``` Implementing this feature will greatly enhance the usability and security of the Docker setup for document scanning processes. Thank you for considering this request.
Author
Owner

@damajor commented on GitHub (Jul 26, 2024):

I use podman rootless and I never had an issue.
Could you explain how you start your container ?

@damajor commented on GitHub (Jul 26, 2024): I use podman rootless and I never had an issue. Could you explain how you start your container ?
Author
Owner

@wggcch commented on GitHub (Jul 26, 2024):

Hi @damajor,
We start it within a custom docker compose file, where we added multiple services
(including openwebui, pipelines ollama and so on)
and mount the /documents dir
So by this method the /volumne dir by default is root owned

and then we just run docker compose up -d

@wggcch commented on GitHub (Jul 26, 2024): Hi @damajor, We start it within a custom docker compose file, where we added multiple services (including openwebui, pipelines ollama and so on) and mount the /documents dir So by this method the /volumne dir by default is root owned and then we just run docker compose up -d
Author
Owner

@damajor commented on GitHub (Jul 26, 2024):

Well I switched to podman to replace docker everywhere so I don't have to mess with such things and I can run any stack as a user, nothing is running as root.
In case of escape, the container root is mapped to the running local user.

Sorry I cant help more.

@damajor commented on GitHub (Jul 26, 2024): Well I switched to podman to replace docker everywhere so I don't have to mess with such things and I can run any stack as a user, nothing is running as root. In case of escape, the container root is mapped to the running local user. Sorry I cant help more.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#1616