-
Notifications
You must be signed in to change notification settings - Fork 137
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
Make UID & GID configurable #147
Comments
Would need explicit approval from someone like @tianon before doing this since it directly changes an "official" image in a new way. |
Alright, even when the default values stay the same? |
Given that Docker has built-in behavior which allows for switching to an arbitrary user (and doing so in a more secure/reliable way than environment variables and/or a shell script could possibly provide) via For a couple implementation examples, see docker-library/rabbitmq#60, docker-library/cassandra#48, docker-library/mongo#81, redis/docker-library-redis#48, docker-library/mysql#161, MariaDB/mariadb-docker#59, docker-library/percona#21, docker-library/ghost#54, docker-library/postgres#253, docker-library/redmine#136. I'd be happy to help take a look here too if that's something you'd be interested in help implementing or reviewing. 👍 ❤️ |
Do I understand right, that this allows me to configure the uid and guid via CLI or compose file to... lets say |
In other words, do I understand "arbitrary" right and are there no further dependencies to |
With the image as it stands right now, it won't work, but it should be possible for the image to be updated to support running with For example, the current In some images, we take the approach of requiring users to pass storage with appropriate permissions instead to avoid having wider permissions on the defaults. |
@tianon I'm trying to run couchdb on openshift which doesn't allow containers to start/run as root - I'm attempting to follow the examples you listed above to allow use of I've put all the chown/chmods in Any guidance/direction would be incredibly helpful, and happy to submit a PR when all is said and done. |
Does the volume you're providing have appropriate permissions for the user you're trying to run as? (or wide enough for that user to create/use it regardless like |
Forgive my lack of docker knowledge - I'm not providing a volume via While digging into this over the past few hours, I think I solved this for openshift - my understanding of openshift is that a random uid is used who exists in gid 0 - so for this use case, I've added the following:
right before the VOLUME directive, as recommended by openshift docs. This works for non-root users in the root group (e.g. Sorry this is a bit of a word salad - there's a lot unknown unknowns for me here, trying my best to grok docker/permissions/openshift/couchdb at once. |
You can probably turn that into a more "generic" solution with |
@drvan We've had a lot of problems with If you're going to do a PR suggesting we change any of that, please review prior bugs on this (I don't have time to dig them out now) before putting the PR up. Thanks :) |
Thanks for the advice all - I've come to realize that my goal (running on OpenShift) is slightly different than the goal discussed here, and much more closely related to #71 , (this comment in particular) but I still feel I can contribute in some shape or form. I've narrowed down what I believe is feasible to one of the following:
Please let me know which approach (if any) you'd like to me to take, and I can submit a PR as soon as possible. @wohali per your note, I've read through the issues you mentioned with respect to chmod and performance, and I'll ensure any proposed change won't re-introduce those issues. |
At IBM we have some work on this (see
https://access.redhat.com/containers/?tab=overview#/registry.connect.redhat.com/ibm/couchdb2).
If it's of interest to the community, we could contribute it to to
https://github.com/apache/couchdb-docker, though the UX may be a little
different to the existing images at the moment.
…On Sun, 11 Aug 2019, 04:25 Ryan Van Antwerp, ***@***.***> wrote:
Thanks for the advice all - I've come to realize that my goal (running on
OpenShift) is slightly different than the goal discussed here, and much
more closely related to #71
<#71> , (this comment in
particular
<#71 (comment)>)
but I still feel I can contribute in some shape or form. I've narrowed down
what I believe is feasible to one of the following:
- Make permissions so wide that any uid/gid can be used (at the
expense of running chmod -R 777 /opt/couchdb which feels like a bad
idea *outside* of a docker container, but not sure if this is accepted
practice in the docker world).
- Modify the image so it can be run completely as couchdb (e.g. --user
5984:5984), but no other user. This aligns much more closely with the
linked PRs above for other images. As an example, you can pull the
cassandra image above, pass --user, but it will *only* work (for me,
at least) if you pass the cassandra uid of 999. This checks the "make the
image able to be run as non-root" box and requires minimal changes, but
some orchestration frameworks don't let you pick an explicit uid easily as
far as I can tell.
- Modify the image so it can be run as any user as long as they belong
to the root group (the OpenShift model). I suspect I'm not the only person
who wants to use this on OpenShift. This would however drastically change
the user/group model, and I'm unsure of any consequences this would
introduce either within the application itself, or through docker.
- Don't modify the image at all, and instead contribute documentation
(somewhere) about how to create a wrapper image so that it can be modified
in any of the above ways.
Please let me know which approach (if any) you'd like to me to take, and I
can submit a PR as soon as possible. @wohali <https://github.com/wohali>
per your note, I've read through the issues you mentioned with respect to
chmod and performance, and I'll ensure any proposed change won't
re-introduce those issues.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#147?email_source=notifications&email_token=AAAX366ZBSX633UJA5DOAVDQD6BD7A5CNFSM4HMVE4NKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4AZHOQ#issuecomment-520197050>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAX36ZYHLAVMIMODZAVDVLQD6BD7ANCNFSM4HMVE4NA>
.
|
Hi @willholley , I think your suggestion is out of scope for this issue. If you would like to pursue this further, please start a new thread on dev@couchdb.apache.org, not in this ticket. Personally, given it's such a major change to the control surface, I think it would be better to defer anything like this until 4.0 - for the principle of least surprise. |
There are other examples which use |
* Adds guards around entrypoints commands that require root * Broaden permissions within the container filesystem to allow access by non-couchdb users. * Added an example to the documentation which specifies `--user`. Fixes #147
Expected Behavior
It should be possible to set the uid or gid for the
couchdb
(linux) user using environment variables.Current Behavior
The uid and gid are hardcoded to the default port
5984
as in #53 decided.Possible Solution
Use the environment variables
PUID
andPGID
to set them.Context
The downside of the decision from #53, implemented in #64, is, that mounted volumes including config files are harder to edit when logged in on the host system with another uid like
1000
. Prefixing them with aP
avoids confusion with ids of the current user.LinuxServer.io wrote about this. They create a user and group
abc
with the id911
and change it with this script in their base images.The text was updated successfully, but these errors were encountered: