fix: running the container with PUID=0 and PGID=0 (#3030)

Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
This commit is contained in:
Jakub Urbańczyk 2024-01-27 17:48:38 +00:00 committed by GitHub
parent 20621a1950
commit 4d49e307e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,18 +12,18 @@ add_user() {
} }
change_user() { change_user() {
# If container is started as root then create a new user and switch to it if [ "$(id -u)" = $PUID ]; then
if [ "$(id -u)" = "0" ]; then echo "
User uid: $PUID
User gid: $PGID
"
elif [ "$(id -u)" = "0" ]; then
# If container is started as root then create a new user and switch to it
add_user add_user
chown -R $PUID:$PGID /app chown -R $PUID:$PGID /app
echo "Switching to dedicated user" echo "Switching to dedicated user"
exec gosu $PUID "$BASH_SOURCE" "$@" exec gosu $PUID "$BASH_SOURCE" "$@"
elif [ "$(id -u)" = $PUID ]; then
echo "
User uid: $PUID
User gid: $PGID
"
fi fi
} }