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

GID already in use #6

Open
xxlbug opened this issue Jan 8, 2023 · 3 comments
Open

GID already in use #6

xxlbug opened this issue Jan 8, 2023 · 3 comments
Labels
wontfix This will not be worked on

Comments

@xxlbug
Copy link

xxlbug commented Jan 8, 2023

Hi there,

thank you for making this, i got really frustrated with gitlab, gitea and gogs. Git-server seems to be all i need and is much leaner :-)

I have a small but important problem which prohibits me from using git-server right now:

On my host system the UID and GID i want to use for git-server are 99/100. On boot i get the error that GID 100 is already in use (from the default group "users" as seen in /etc/group).

08/01/2023 21:36:15 deluser: can't find git in /etc/group 08/01/2023 21:36:15 addgroup: gid '100' in use 08/01/2023 21:36:16 id: unknown user git 08/01/2023 21:36:16 deluser: unknown user git

I could change the dockerfile to manually change the gids around but wanted to try to find a better solution which also avoids this problem in the future for others.

My ideas so far:

  • if the uid/gid is already in use inside the image, just take it instead of the "git" user/group, only the ids are important not the name
  • have some kind of logic to reassign the default uid/gids of alpine to something like 999999 in case of conflict
  • delete everything from the uid/gids in this image which is not absolutly necessary to avoid conflicts as far as possible (but wouldn't help me, since nobody is a system group, i think)
  • allow only the given uid or gid to be assigned, not both in case only uid is given

I can make the changes and create an PR but would like to have some input before.

Thank you

@rockstorm101 rockstorm101 added the bug Something isn't working label Jan 9, 2023
@rockstorm101
Copy link
Owner

Hi @xxlbug, thanks for reporting this. I am able to reproduce it. I totally overlooked this potential use case. I'll think about it and what could be the best approach to work around it.

@rockstorm101
Copy link
Owner

After giving this some thought I would say the current behavior is the right one. Modifying/deleting system users/groups must be handled with care. The logic to do so (without installing any additional packages) goes far beyond the currently supplied simple setup script. Plus, I don't expect many users to stumble across conflicts with system user/group IDs to be honest. Most hosts will use IDs greater than 1000 for their user IDs. Let me know if you think otherwise.

For those that face errors like:

addgroup: gid '100' in use
adduser: uid '100' in use

Instead of modifying the Dockerfile, the current setup allows for custom scripts to be run during container initialization. One can create a script, e.g. 01-mod-system-users.sh, and mount it at /docker-entrypoint.d/. This way it will be run before the setup script (i.e. 10-setup.sh).

services:
  git-server:
    ...
    volumes:
      - ./01-mod-system-users.sh:/docker-entrypoint.d/01-mod-system-users.sh:ro

In this particular case, modifying the system users/groups to allow for UID:GID combination 99:100 to be used for git is pretty straight forward since those UID:GID do not own any files in the system. No delicate file ownership changes are required.

#!/bin/sh

deluser guest
delgroup users
addgroup -g 101 -S users
addgroup games users
adduser -u 405 -G users -h /dev/null -g 'guest' -S guest
delgroup guest users

So I'm inclined not to fix this issue but leave it open for future reference in case someone else finds the same problem. I know it is not great but I could not come up with an easy, quick and elegant way to allow for virtually any UID and GID to be used.

I'm open to suggestions on any aspect and from anyone, so please keep them coming and thanks for contributing.

@rockstorm101 rockstorm101 added wontfix This will not be worked on and removed bug Something isn't working labels Jan 10, 2023
@xxlbug
Copy link
Author

xxlbug commented Jan 15, 2023

@rockstorm101 thank you for the advice and script, it works now fine. I think it would be best to close this ticket and let people look in the closed tickets to search for solved problems. But up to you :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants