diff --git a/docker/setup/entrypoint.sh b/docker/setup/entrypoint.sh index efd9eb1f0..5b17b3d7c 100755 --- a/docker/setup/entrypoint.sh +++ b/docker/setup/entrypoint.sh @@ -12,12 +12,15 @@ set -euo pipefail # at the end of the dockerfile ldconfig -# Add the group of the user. User/group ID of the host user are set through env variables when calling docker run further down. +# Remove any existing user with the same name (userdel may also remove its primary group) +userdel "$DOCKER_RUN_USER_NAME" 2>/dev/null || true +userdel ubuntu 2>/dev/null || true + +# Add the group of the user AFTER userdel, since userdel may have removed the primary group. +# User/group ID of the host user are set through env variables when calling docker run further down. groupadd --force --gid "$DOCKER_RUN_GROUP_ID" "$DOCKER_RUN_GROUP_NAME" # Re-add the user -userdel "$DOCKER_RUN_USER_NAME" 2>/dev/null || true -userdel ubuntu || true useradd --no-log-init \ --uid "$DOCKER_RUN_USER_ID" \ --gid "$DOCKER_RUN_GROUP_NAME" \