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

map uid/guid to different ids #210

Open
bsutton opened this issue Aug 15, 2024 · 6 comments
Open

map uid/guid to different ids #210

bsutton opened this issue Aug 15, 2024 · 6 comments

Comments

@bsutton
Copy link

bsutton commented Aug 15, 2024

My understanding is that when postfix starts it uses a couple of user/group that are mapping to uid 101/102.

My problem is that I need this group to read the config folder from the host.

On the host the uid 101 maps to is something like system-journal, this means that on the host I have to give the postfix config file are rather confusing looking permission.

Is there some what to force the postfix container to use alternate uid/gids so that I can map them to unused uid/gids on the host.
I can then create a postfix user on the host with the same uid as the containers postfix user and my host permissions now look sensible.

@bsutton
Copy link
Author

bsutton commented Aug 15, 2024

I note that your documentation states:

While I cannot guarantee IDs (they are auto-generated by package manages), they tend to be fairly consistent across specific distribution. Please be aware of this if you are switching images from Alpine to Debian to Ubuntu or back.

I don't believe this is correct because if you create the users/groups before running the package manager they should use the existing uid/guid.

I play a similar game for the maria db container:

# add our user and group first to make sure their IDs get assigned consistently

RUN groupadd -g 2002 -r mysql && useradd -u 2002 -r -g mysql mysql --home-dir /var/lib/mysql

So if the container where to take a couple of env vars with the desired uid/gid then I think that would provide a solution.

@bokysan
Copy link
Owner

bokysan commented Aug 15, 2024

HI Brett,

Thank you for your comment. Unfortunately, (system) users are assigned to apps when the container is built, not when it's run.

So implementing ENV vars would do nothing more than fail to start the container if you were to change them.

If you do have any good ideas, I'm open to pull requests.

B

@bsutton
Copy link
Author

bsutton commented Aug 15, 2024 via email

@bokysan
Copy link
Owner

bokysan commented Sep 15, 2024

@bsutton While assigning higher IDs most likely will cause less collision, we still do not eliminate it.

Another issue is changing the IDs now would cause a lot of headache to existing users, as their images would suddenly stop working.

I certainly do not have a good way out of this. Any other ideas?

@bsutton
Copy link
Author

bsutton commented Sep 17, 2024 via email

@bokysan
Copy link
Owner

bokysan commented Oct 17, 2024

I can live with that. Passing IDs at a build time is done in Dockerfile via ARG instruction and then via --build-arg when running docker build.

What would need to be done here:

  1. Add ARG instruction to Dockerfile
  2. Change the build script to take it into account if set
  3. Ensure that it works on all flavours (Debian / Ubuntu / Alpine)
  4. Ensure that if not set, the defaults persist.
  5. Update documentation to explain how to build this yourself with different IDs.

Frankly, I don't see this as a high-priority feature, but if you would like to take a crack at it, I'd be more than happy to accept 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