Drop Stash to non privileged user in Docker container - #7153
Closed
aserv92 wants to merge 4 commits into
Closed
Conversation
aserv92
marked this pull request as draft
August 11, 2026 23:08
aserv92
force-pushed
the
drop-stash-to-local-user-in-dcr-container
branch
2 times, most recently
from
August 11, 2026 23:32
6e81df9 to
cfb9c33
Compare
aserv92
force-pushed
the
drop-stash-to-local-user-in-dcr-container
branch
2 times, most recently
from
August 11, 2026 23:45
6d731a7 to
8518ec0
Compare
aserv92
force-pushed
the
drop-stash-to-local-user-in-dcr-container
branch
from
August 12, 2026 01:16
bd6627b to
0fb09a9
Compare
aserv92
marked this pull request as ready for review
August 12, 2026 02:12
aserv92
force-pushed
the
drop-stash-to-local-user-in-dcr-container
branch
from
August 12, 2026 02:25
0fb09a9 to
67e3c45
Compare
Author
|
@DogmaDragon I would like to request review from the code owner. But seems i'm not allowed to. |
Author
|
I closed this PR as no review was left and there is no way to move forward with this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add option to run Stash as a non-root user from Docker containers perspective and generated files to be owned by the specified user.
Related Issue
#684
Testing
make docker-buildpnpmconfiguration/version (unrelated) so I temporarily bypassed it by addingRUN corepack enableto the build front end stage of the Docker builddocker/productiondirectorymkdir blobs cache config data generated metadata(see explanation in additional context)docker.io/stash/build:latestdocker compose upI also executed

make docker-cuda-buildto build and test the Cuda build then followed the exact same steps.its worth mentioning that the build failed for the
pnpmversion mismatch so I temporarily fixed the same way I fixed it in the non Cuda test. Also the imagegolang:1.25.9-bullseyedoes not exist at the time of making this PR so I updated the cuda build to usegolang:1.25.9-trixieas the backend base.Ahhh. Yes, from the Cuda containers perspective ubuntu owns the files generated by stash instead of stash. This is because my host user is user 1000 and the base ubuntu container already has user 1000 and is named ubuntu it skipped creating the stash user with ID 1000 because the ubuntu user already exists and has user id 1000. This is expected behavior. I'll change the user id in the compose yml to user id 1005 and upload one more screen shot. You will see now from the container perspective the stash files are owned by stash and from my perspective the files are owned by undefined user 1005 because my local system doesn't have a user 1005.

See diff used for testing
This is how I tested the changes. I didn't want to include these changes in the PR as they are unrelated to the issue.
Screenshots
Checklist
AI Usage Disclosure
Additional Context
It is worth mentioning that when we mount a local directory as a volume, if it doesn't exist before docker creates the container docker (using it's own permission, generally root) will create the directory. This is also expected docker behavior. So the directories need to exist before docker starts the container otherwise root will own the directories then stash will fail to put files in the directories as stash is now running as non root and can not manipulate files in directories owned by root.
I understand there are concerns about not be able to run as root breaking things. These changes to the docker builds do allow running stash as root as well.
Although if your worried about breaking current installs/setups/workflows then I can update this PR to run the container as root by default. But I think that leaves security vulnerabilities on the table as does anything running with unnecessary elevated privileges.
Yes I am bounty hunting, but I am human. No AI was used to make this PR.