dst-dedicated-server icon indicating copy to clipboard operation
dst-dedicated-server copied to clipboard

Binding container to default user

Open thatjames opened this issue 5 years ago • 1 comments

Set PUID and PGID to the default linux user 1000

thatjames avatar Jul 31 '19 19:07 thatjames

Hey @thatjames, thanks for contributing!

I would propose we review this in more depth before merging. While UID/GID 1000 would work for "default" cases, it would fail in any other cases where the user's UID/GID mismatch that value. I see you added a comment there to find the current user's IDs, but I'm afraid most people would miss that, specially those not so quite acquainted with Docker yet.

I know that Docker Compose supports variable substitution, allowing to parse shell variables into the compose file. I fiddled with it a bit and unfortunately it doesn't seem to parse shell commands (e.g. $(id -u) and $(id -g)) which would be optimal as it would solve it for all platforms.

I see that $UID and $GID variables are available in some shells (bash/ksh/zsh), so I guess it's closer to an optimal solution, but it won't work if using sh for instance. We could use them as such in docker-compose.yml:

  - PUID=$UID
  - PGID=$GID

However, since that's still not a bulletproof solution, I would rather have it as an optional workaround, i.e. have it commented out in docker-compose.yml. On regular cases with a proper Docker installation and user setup, these parameters should not be needed at all (me and others have ran this project in several different OSX and Linux distributions successfully). We could then add a "Troubleshooting" section to the docs and point to these commented out lines, instructing people to uncomment them and how to fetch their UID with id -u should those variables not be available in their shells.

What do you think of it?

mathielo avatar Aug 04 '19 15:08 mathielo