You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhancement/build: allow container image to run as nonroot #1103
Is your feature request related to a problem? Please describe.
Per title. I am aware of similar past issues [1][2] , but I found it weird that we have to take extra steps just to run this thing as nonroot (considering that this is just a simple client-server application).
Describe the solution you'd like
Per docker best practices and seeing the docker files of other FOSS projs, a way to achieve this is to use gosu, which I exactly did in this PR
Although, I made port 8080 as the default since I can't bind to privileged ports 1-1000 as nonroot. This might be a regression worth considering.
Describe alternatives you've considered
Alternative solution also suggested by the best practices doc is to hardcode the user directly via USER directive directly but I felt that this approach wasn't really that flexible
changed the title [-]Enhancmenet/build: allow container image to run as nonroot[/-][+]Enhancement/build: allow container image to run as nonroot[/+]on Dec 3, 2026
but I found it weird that we have to take extra steps just to run this thing as nonroot (considering that this is just a simple client-server application).
I think my answer 8 years ago was outdated. It seems like the current preferred way to do this in docker is standalone volumes:
Also if you are using podman, etc, if I recall correctly there is a :U mount option which will do what you want and change the ownership automatically.
Hi. I don't think it matters if you run it via bindmount or docker volume. The config and data directory is still owned by root making the container fail at first launch (which you'll have to manually chown). Default port is also 80 so not good for nonroot users
That's what my PR addresses (changing the entrypoint).
$ docker run --name gotilatest --pull=always -d --user 9999:9999 -e GOTIFY_SERVER_PORT=8080 gotify/server
latest: Pulling from gotify/server
Digest: sha256:44fc5bbd1c0618878e33073d38c2c13126b48f245c3fe12236b1da48eb203b86
Status: Image is up to date for gotify/server:latest
a1ddf013e4ca71ec07017fdfaed469840124879955021f73be76edcd96cb48f7
$ docker ps -a | grep gotilatest
a1ddf013e4ca gotify/server "./gotify-app serve" 3 seconds ago Exited (1) 2 seconds ago gotilatest
$ docker logs gotilatest
2026-12-04T15:33:23Z INF Gotify build_date=2026-09-15-18:26:53 version=3.1.1
2026-12-04T15:33:23Z ERR Cannot create plugins directory error="mkdir data: permission denied" dir=data/plugins
Thanks for the input, I understand but this would be a pretty big breaking change and I'm trying to weigh in the pros and cons. From my point of view:
Regarding the UID setting and default bind port: That can be changed, I agree, although maybe it can be solved just with a setcap binary and a built-in UID and/or capability transition after the listener is established? I can try something this weekend and see if we can avoid breaking existing port mappings
Regarding the ownership issue I have some reservations:
Regarding the changes in Enhancement: allow container image to run as nonroot #1104, after reserving a unique UID and GID, afaik there is only a single manual command required (mkdir and then chown). I am not super sure why is the status quo more cubersome than looking up a specific environment variable like GOTIFY_USER (instead of the standard --user), especially considering that this is somewhat counterintuitive that usernames does not work and you have to pass raw UID/GIDs.
In rootless/namespace based container runtime(s) like podman where it can be tricky to compute the correct UID/GID for a rootless container in a rootless runtime, they already have the solution built in (you simply append ":U" to the volume in your compose.yml and it automatically create the directory with the right ownership), so this is largely a (rootful) docker specific issue. the docker team already has a stance that it's generally not a good idea to mass chown things automatically when you run a container, which I think is important to reference
Activity
[-]Enhancmenet/build: allow container image to run as nonroot[/-][+]Enhancement/build: allow container image to run as nonroot[/+]eternal-flame-AD commentedon Dec 3, 2026
I think my answer 8 years ago was outdated. It seems like the current preferred way to do this in docker is standalone volumes:
https://forums.docker.com/t/bind-mount-with-current-users-ownership/147176
Also if you are using podman, etc, if I recall correctly there is a :U mount option which will do what you want and change the ownership automatically.
Euge908 commentedon Dec 4, 2026
Hi. I don't think it matters if you run it via bindmount or docker volume. The config and data directory is still owned by root making the container fail at first launch (which you'll have to manually chown). Default port is also 80 so not good for nonroot users
That's what my PR addresses (changing the entrypoint).
eternal-flame-AD commentedon Dec 4, 2026
Thanks for the input, I understand but this would be a pretty big breaking change and I'm trying to weigh in the pros and cons. From my point of view:
Regarding the UID setting and default bind port: That can be changed, I agree, although maybe it can be solved just with a setcap binary and a built-in UID and/or capability transition after the listener is established? I can try something this weekend and see if we can avoid breaking existing port mappings
Regarding the ownership issue I have some reservations:
--user), especially considering that this is somewhat counterintuitive that usernames does not work and you have to pass raw UID/GIDs.