-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
docker build scripts assume user id to be 1000 (uid) #8261
Comments
alternative solution: use |
Note: Might be problematic w.r.t reproducibility |
- repro builds to use fixed uid=1000 inside the container - in case the file permissions leak into the binaries, they are still reproducible - chown 1000:1000 fresh_clone - repro builds to create fresh_clone dir outside git clone - otherwise the local dev build would still interact with the fresh_clone dir - due to e.g. recursive "find -exec touch", - and even the "docker build" cmd itself would try to stat/read it - see docker/for-linux#380 - and "rm -rf fresh_clone" needs sudo if the host uid is not 1000 - this way the local dev build does not need sudo to recap: - local dev builds use the host userid inside the container, directly operate on the project dir - does not need sudo - repro builds create a fresh git clone, chown it to 1000, and use userid=1000 inside the container - if the host userid is 1000, does not need sudo - otherwise, needs sudo closes spesmilo#8261
- repro builds to use fixed uid=1000 inside the container - in case the file permissions leak into the binaries, they are still reproducible - chown 1000:1000 fresh_clone - repro builds to create fresh_clone dir outside git clone - otherwise the local dev build would still interact with the fresh_clone dir - due to e.g. recursive "find -exec touch", - and even the "docker build" cmd itself would try to stat/read it - see docker/for-linux#380 - and "rm -rf fresh_clone" needs sudo if the host uid is not 1000 - this way the local dev build does not need sudo to recap: - local dev builds use the host userid inside the container, directly operate on the project dir - does not need sudo - repro builds create a fresh git clone, chown it to 1000, and use userid=1000 inside the container - if the host userid is 1000, does not need sudo - otherwise, needs sudo closes spesmilo#8261
Great idea!
Indeed. I was also thinking about that... We can differentiate local dev builds and reproducible builds, and only use your idea in the former case though. |
Btw, just as context, I bumped into this bug and want to fix it now as I have set up a server I would like to build on but am already using userid=1000 for other things. |
- repro builds to use fixed uid=1000 inside the container - in case the file permissions leak into the binaries, they are still reproducible - chown 1000:1000 fresh_clone - repro builds to create fresh_clone dir outside git clone - otherwise the local dev build would still interact with the fresh_clone dir - due to e.g. recursive "find -exec touch", - and even the "docker build" cmd itself would try to stat/read it - see docker/for-linux#380 - and "rm -rf fresh_clone" needs sudo if the host uid is not 1000 - this way the local dev build does not need sudo to recap: - local dev builds use the host userid inside the container, directly operate on the project dir - does not need sudo - repro builds create a fresh git clone, chown it to 1000, and use userid=1000 inside the container - if the host userid is 1000, does not need sudo - otherwise, needs sudo closes spesmilo#8261
I recently realised that most of our build scripts only work when run with uid==1000.
I guess this just happens to be the case for everyone who cares to run them. :P
The issue is that we mount the local git clone with
docker run -v
and work on that directly:electrum/contrib/build-wine/build.sh
Lines 47 to 49 in d8abab3
Inside the container, the local git clone will have numerically the same uid/gid owner.
The unix user inside the container is created via
useradd
, and this starts numbering uids from 1000.electrum/contrib/build-wine/Dockerfile
Line 66 in d8abab3
So due to the -v mount, the unix user inside the container needs matching user id with the host unix user, and due to the
useradd
, the container's unix user will have uid==1000, hence the host unix user also needs to have uid==1000.I guess this is likely a regression from #7697.
Not clear how to fix cleanly.
related:
moby/moby#7198
https://stackoverflow.com/q/39397548
https://stackoverflow.com/a/45640469
coder/code-server#439
The text was updated successfully, but these errors were encountered: