-
Notifications
You must be signed in to change notification settings - Fork 7
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
Standardise method for mapping uid/gid inside the container with uid/gid outside the container #5
Comments
Some overlap with #6 e.g.
Running So... Need to make sure that any standard solution to this issue work both when $PWD is bound to /tmp/workspace, as well as when /tmp/workspace comes from a sidekick container. Potentially the default solution here is that when you're running a container against a git repo, do not pass in user ids into either the git container or the task container. Rather, just require that the uid inside both containers match. Again though, this should be configurable globally to the app, as well as to the individual task. |
Also, kinda related, but we seriously need a better way of doing this than passing in environment variables. For example: |
Also worth considering not passing in any uid at all on OSs which do not require it. e.g. Docker for Mac does this uid mapping for you, so Cali should (optionally) detect that and refrain from passing in UID/GID in this case. |
I have a possible fix to this issue. My code has been heavily refactored, but the fix is only one additional function. The logic is simple since is something I already did as bash scripts a while ago:
Right now the fix applies every execution of |
Oh, that's cool. That script looks similar to what I'm doing in my Cali app. Think we got that idea from the same place :) I would say we probably don't want to include that in every container by default (given a container could contain anything), but maybe have it as an option. Such a script would need customising based on the base OS of the container, e.g. alpine vs centos vs debian vs whatever ( I like the idea of committing the container, for future uses on the same machine too. |
I got it from staticli, I guess you and @wheresalice are working together in this? :) As I see it, Another solution is to offer it as an additional entrypoint of the API so you can do something like
Of course the script should fix several types of platforms, but that shouldn't be hard and is easy to expand. |
Is not the most elegant solutions but works now for me: |
The users remapping flag involves touching the docker daemon. I think is not an option for this feature. |
For use with gosu or su-exec, e.g.
https://denibertovic.com/posts/handling-permissions-with-docker-volumes/
On a linux host, if you bind a volume from the host into the container, but then run as root in the container, any new files will be owned by root, both inside the container and outside.
To work around this, you need a specially crafted docker image.
e.g.
lucymhdavies/docker-images@b4f9b85
And you need to set environment vars when running the container
e.g. in lucli I have used HOST_USER_ID and HOST_GROUP_ID
https://github.com/LMHD/lucli/blob/52fd09f647706af0939e90d9620e4a52b8a8204f/cmd/vim.go#L16-L21
Fix:
While we can't 'fix' the issue, we can standardise what appears to be the popular workaround.
By default, Cali should set HOST_USER_ID and HOST_GROUP_ID environment variables for all containers it runs.
These environment variables should also be configurable in the app which uses the Cali library, and configurable on each individual task too.
The text was updated successfully, but these errors were encountered: