-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Allow use of dynamic user in fig #939
Comments
A very similar feature like this has been suggested in #495 |
What's the use case? With environment variable support, passing in |
@aanand From what I can tell, these two fig.yaml files behave very differently: Setting
Setting
In the first case, when setting the user, files generated with a However, when setting the environment variable "USER", the files are all still created with It would be really nice to be able to set the user in the |
#737 is related to this |
Using the approach I proposed in #1006 we could provide a safe variable substitution. This could include eg: %%user%% and %%group%% variables. Those variables will be resolved via python (and not prone to shell-expansion) |
It would be nice if you could have environment variables in docker-compose.yml that are substituted by python when the file is read. For example, you could have user: $UID in a service so it runs as the same user that is running docker-compose. This is useful for development scenarios among other things where containers might generate files you then want to edit. |
@aanand asked for a use case:In development, I want to bind mount My development container needs to be able to build As a workaround, I currently build as root, which sucks, and results in files that In an ideal world, I would ensure that (Finally, I'd like to instruct my colleagues to just run |
With environment interpolation and We also have |
👍 Can you please give an example of how to use the environment interpolation? |
The docs are here: https://github.com/docker/compose/blob/master/docs/yml.md#variable-substitution The feature is in master, and will be in the web:
user: ${USER}
... |
How does this help? The |
is completely useless when the user-string is not known inside docker...
|
Yes, you have to create the user in the image first. |
So what if you create a user in the image? That still doesn't help me set the UID and GID to match the ones in the host so I could mount the current project directory in the container and do, say, |
Hi there, Don't know if this questions still pops-up now, but here is the thing: Why couldn't you set the UID / GID to match the ones in the host ? For example, if I need to use composer in my image, then I just have to define a useradd line BEFORE it in the compose file. then telling my compose-file to use this user, with "USER ". If you want to do things properly, use uids, and not names. So that you can even map host user to another username in VM keeping the same ids, which can be very useful sometimes (depending on what you want to do) |
hello world, I was wondering if i could mount /etc/group and /etc/passwd as ro and than in my docker-compose.yml file
has anyone tried that? |
Why only on the If there is a way to use Also I agree with PandaaRun that using user ids is much more properly done than using user names. |
Is it possible to specify an entrypoint that creates the correct username, uid and guid... then get that custom entrypoint (mounted in at runtime) to exec the default one. That way you don't have to rebuild maintained docker images. Would the environment variables user: ${UID}:${GROUPS} always result in the correct uid:gid combo? |
It would be nice if fig could do the same as:
This way one would be able to set the same user user/group as the current user without having to set manually each time for every different user.
(using this would make the files created within the container to be with the same permission of the actual user)
The text was updated successfully, but these errors were encountered: