Skip to content

Commit 957ba59

Browse files
WhyNotHugomark9064
authored andcommitted
docs: --user is only required when docker run as root
The --user argument attempts to map the uid of the user inside the container to the user in the host. This works if docker is running as root, but is docker is running as the current user, then the uid in the container is mapped to a surrogate uid on the host, and this surrogate user does not have permissions to complete the build process. Clarify that the --user flag is only required when running docker as root. It is also likely not required by users using podman as a docker drop-in replacement, since podman always runs in rootless mode.
1 parent 09b1342 commit 957ba59

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

doc/buildWithDocker.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,20 @@ Outputs will be written to **<project_root>/build/output**:
6565

6666
```sh
6767
cd <project_root> # e.g. cd ./work/Pinetime
68-
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime-build
68+
docker run --rm -it -v ${PWD}:/sources infinitime-build
6969
```
7070

71-
By default, the container runs as `root`, which is not convenient as all the files generated by the build will also belong to `root`.
72-
The parameter `--user` overrides that default behavior.
73-
The command above will run as your current user.
71+
If the docker service is running as `root`, the build process inside the
72+
container also runs as `root`, which is not convenient as all the files
73+
generated by the build will also belong to `root`. The parameter `--user`
74+
overrides this behaviour. The command below ensures that all files are created
75+
as your current user:
76+
77+
78+
```sh
79+
cd <project_root> # e.g. cd ./work/Pinetime
80+
docker run --rm -it -v ${PWD}:/sources --user $(id -u):$(id -g) infinitime-build
81+
```
7482

7583
If you only want to build a single CMake target, you can pass it in as the first parameter to the build script.
7684
This means calling the script explicitly as it will override the `CMD`.

0 commit comments

Comments
 (0)