Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please update your Dockerfile to not use a hardcoded 1000 uid #258

Open
electrofloat opened this issue Jan 28, 2023 · 3 comments
Open

Please update your Dockerfile to not use a hardcoded 1000 uid #258

electrofloat opened this issue Jan 28, 2023 · 3 comments

Comments

@electrofloat
Copy link

Using id 1000 is very restrictive.

Would be a tons better if one could just give the uid/gid through env variables like what linuxserver.io does:
https://docs.linuxserver.io/general/understanding-puid-and-pgid

@psi-4ward
Copy link
Owner

That's the standard of node:alpine. But feel free to make some suggestions

@electrofloat
Copy link
Author

electrofloat commented Jan 28, 2023

Yes. That's why I'm suggesting to do the same as linuxserver does. (https://github.com/linuxserver/docker-baseimage-alpine/blob/master/root/etc/s6-overlay/s6-rc.d/init-adduser/run)
Use PUID and PGID env variables (which will be given by the user creating the container with --env), and either create a new user in your image with those ids for ex.:

groupmod -o -g "$PGID" abc
usermod -o -u "$PUID" abc
.
.
chown abc:abc /folder_used_by_your_app

or change the uid/gid of use node to the one provided in the env variables, for ex.:

usermod -u "$PUID" node
groupmod -g "$PGID" nodegroup
.
.
find / -group "$PGID" -exec chgrp -h nodegroup {} \;
find / -user "$PUID" -exec chown -h node {} \;

The last one of course assumes that the numbers given through env are available in the image itself, so probably the first one is safer to use.

@psi-4ward
Copy link
Owner

If you like prep a pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants