Support explicit non-root Docker users - #7159
Conversation
aserv92
left a comment
There was a problem hiding this comment.
I also have concerns about running stash as a user that does not actually exist from the containers perspective.
| if [ "$(id -u)" -eq 0 ]; then | ||
| exec /usr/local/bin/nvidia-patch-entrypoint.sh "$@" | ||
| fi | ||
|
|
||
| exec "$@" |
There was a problem hiding this comment.
The current implementation will re-run stash (one more time) when the user ID is 0 (root) and stash exits with exit code 0 on the first run.
| if [ "$(id -u)" -eq 0 ]; then | |
| exec /usr/local/bin/nvidia-patch-entrypoint.sh "$@" | |
| fi | |
| exec "$@" | |
| if [ "$(id -u)" -eq 0 ]; then | |
| exec /usr/local/bin/nvidia-patch-entrypoint.sh "$@" | |
| else | |
| exec "$@" | |
| fi |
or
| if [ "$(id -u)" -eq 0 ]; then | |
| exec /usr/local/bin/nvidia-patch-entrypoint.sh "$@" | |
| fi | |
| exec "$@" | |
| if [ "$(id -u)" -eq 0 ]; then | |
| exec /usr/local/bin/nvidia-patch-entrypoint.sh "$@" | |
| exit $? | |
| fi | |
| exec "$@" |
| ADD --chmod=555 https://raw.githubusercontent.com/keylase/nvidia-patch/master/patch.sh /usr/local/bin/patch.sh | ||
| ADD --chmod=555 https://raw.githubusercontent.com/keylase/nvidia-patch/master/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | ||
| ADD --chmod=555 https://raw.githubusercontent.com/keylase/nvidia-patch/master/docker-entrypoint.sh /usr/local/bin/nvidia-patch-entrypoint.sh | ||
| COPY --chmod=555 ./docker/build/x86_64/cuda-entrypoint.sh /usr/local/bin/docker-entrypoint.sh |
There was a problem hiding this comment.
I recommend using a better name for the entry point as both entry points are docker entry points.
|
These are interesting suggestions ngl, appreciate you taking the time. Sorry I didn't see them earlier, GitHub didn't really notify me in my inbox or email haha. I took the naming point and changed the wrapper to I took another look at the Thanks again. |
Description
I went through the previous attempts and the rootless guide before working on this. I ended up keeping the current image behavior unchanged and relying on Docker's own
user: UID:GIDsupport instead of adding another PUID/PGID entrypoint.The main thing in the way was Stash trying to look up the current user. Numeric container users don't always exist in
/etc/passwd, so Stash now usesHOMEfirst and falls back to the previous lookup when needed. The compose example shows the matching home and config settings without changing anything for existing installations.CUDA actually needed a small exception because its optional NVIDIA patch writes to system directories. It still works exactly as before when running as root, while a non-root container skips the patch and starts Stash normally.
Related Issue
Closes #684.
Testing
I tested this with UID/GID
12345:23456and no matching user entry, and success! Stash started in the official image, responded over HTTP, and wrote files with the expected ownership.The Go tests, configuration tests, Compose validation, shell checks and full backend build also pass. Should be good to go.
Screenshots
Not applicable.
Checklist
AI Usage Disclosure
I used Codex while researching the previous attempts, tidying/tying up the implementation and running some tests. I reviewed all of its changes and take full responsibility for them.
On a side note, sorry again for the earlier PR missing the template, sometimes I skip through reading unintentionally. Appreciate your patience.