tianocore / containers

Repository to maintain and manage edk2 containers
Other
20 stars 25 forks source link

Cannot run in a rootless container using podman #76

Open yanjiew1 opened 1 year ago

yanjiew1 commented 1 year ago

Describe the bug The startup script in dev-variant container assumes that it is not run in a user namespace. However, it is not true when using a rootless container. When it is run in a rootless container, uid 0 in the container will be mapped to the user who starts the container.

The startup script will try to create a user with uid 0 and the creation will fail with the error message.

useradd: UID 0 is not unique

To Reproduce Run the dev container using podman as normal user:

podman run -it \
       -v "${HOME}":"${HOME}" -e EDK2_DOCKER_USER_HOME="${HOME}" \
       ghcr.io/tianocore/containers/ubuntu-20-dev:latest /bin/bash

Expected behavior The container starts successfully and we can see the shell prompt.

Execution environment Host OS: Ubuntu 22.04 Container Engine: podman version 4.5.0 Podman command run as normal user:

podman run -it \
       -v "${HOME}":"${HOME}" -e EDK2_DOCKER_USER_HOME="${HOME}" \
       ghcr.io/tianocore/containers/ubuntu-20-dev:latest /bin/bash

Additional context Add any other context about the problem here.

osteffenrh commented 1 year ago

I can confirm that.

Maybe a check if the uid is already 0 and then skip useradd will do the trick?