Linux AppImage build fails if run as root
- Dominant language
- Python
- Stars
- 3.3k
- Forks
- 549
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 40
Description
Reported by @axel-kah
If you run a `briefcase create linux` build while logged in as root, it attemps to build the Docker container with HOST_UID and HOST_GID set to 0. This causes the `useradd` step to fail:
```
Step 12/16 : ARG HOST_UID
---> Running in 063a424d6a86
Removing intermediate container 063a424d6a86
---> 4657e96c180d
Step 13/16 : ARG HOST_GID
---> Running in a59336d3cdb7
Removing intermediate container a59336d3cdb7
---> 4fede95af7ee
Step 14/16 : RUN groupadd --gid $HOST_GID briefcase || true
---> Running in bb37131e7a73
groupadd: GID '0' already exists
Removing intermediate container bb37131e7a73
---> a94d6f409c76
Step 15/16 : RUN useradd --uid $HOST_UID --gid $HOST_GID brutus --home /home/brutus
---> Running in 55dc8b2957d8
useradd: UID 0 is not unique
The command '/bin/sh -c useradd --uid $HOST_UID --gid $HOST_GID brutus --home /home/brutus' returned a non-zero code: 4
Error building Docker container for helloworld.
```
This is because the default user in Docker is root, with UID 0.
We need to either:
a. Modify the docker container to be resilient to UIDs that already exist, or
b. Add error handling to prevent briefcase from being invoked with users that already exist.
Contributor guide
Assessment
This issue has not been assessed yet.