From 9996647eaa48a25ff3a6062cc845179ae5c26d57 Mon Sep 17 00:00:00 2001 From: Marc Toensing Date: Wed, 21 Aug 2024 21:55:11 +0200 Subject: [PATCH 1/3] fixes fatal: The GID `1000' is already in use. --- docker-entrypoint.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index d0e712a..d2f0d1c 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -11,18 +11,26 @@ if ! id "$DOCKER_USER" >/dev/null 2>&1; then GROUP_ID=${PGID:-9001} echo "Starting with $USER_ID:$GROUP_ID (UID:GID)" - addgroup --gid $GROUP_ID $DOCKER_GROUP - adduser $DOCKER_USER --shell /bin/sh --uid $USER_ID --ingroup $DOCKER_GROUP --disabled-password --gecos "" + # Check if the desired GROUP_ID is already in use + if getent group $GROUP_ID >/dev/null 2>&1; then + EXISTING_GROUP=$(getent group $GROUP_ID | cut -d: -f1) + echo "GID $GROUP_ID is already in use by group $EXISTING_GROUP. Using this group." + else + addgroup --gid $GROUP_ID $DOCKER_GROUP + echo "Created group $DOCKER_GROUP with GID $GROUP_ID." + fi + + # Create user with the specified UID and existing or new group + adduser --shell /bin/sh --uid $USER_ID --ingroup $DOCKER_GROUP --disabled-password --gecos "" $DOCKER_USER + # Set ownership and permissions chown -vR $USER_ID:$GROUP_ID /opt/minecraft chmod -vR ug+rwx /opt/minecraft - if [ "$SKIP_PERM_CHECK" != "true" ] - then + if [ "$SKIP_PERM_CHECK" != "true" ]; then chown -vR $USER_ID:$GROUP_ID /data fi fi export HOME=/home/$DOCKER_USER -exec gosu $DOCKER_USER:$DOCKER_GROUP java -jar -Xms$MEMORYSIZE -Xmx$MEMORYSIZE $JAVAFLAGS /opt/minecraft/paperspigot.jar $PAPERMC_FLAGS nogui - \ No newline at end of file +exec gosu $DOCKER_USER:$DOCKER_GROUP java -jar -Xms$MEMORYSIZE -Xmx$MEMORYSIZE $JAVAFLAGS /opt/minecraft/paperspigot.jar $PAPERMC_FLAGS nogui \ No newline at end of file From a4795c8c98577e0f4a98ce4e4b40bd4dbd169620 Mon Sep 17 00:00:00 2001 From: Marc Toensing Date: Wed, 21 Aug 2024 23:09:37 +0200 Subject: [PATCH 2/3] still trying to fix the " fatal: The GID `1000' is already in use" error --- docker-entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index d2f0d1c..0e78868 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -15,12 +15,13 @@ if ! id "$DOCKER_USER" >/dev/null 2>&1; then if getent group $GROUP_ID >/dev/null 2>&1; then EXISTING_GROUP=$(getent group $GROUP_ID | cut -d: -f1) echo "GID $GROUP_ID is already in use by group $EXISTING_GROUP. Using this group." + DOCKER_GROUP=$EXISTING_GROUP else addgroup --gid $GROUP_ID $DOCKER_GROUP echo "Created group $DOCKER_GROUP with GID $GROUP_ID." fi - # Create user with the specified UID and existing or new group + # Create user with the specified UID and associated group adduser --shell /bin/sh --uid $USER_ID --ingroup $DOCKER_GROUP --disabled-password --gecos "" $DOCKER_USER # Set ownership and permissions From b6d0f047d13a30be7c3e663281ebe30dacd1af61 Mon Sep 17 00:00:00 2001 From: Marc Toensing Date: Thu, 22 Aug 2024 10:08:58 +0200 Subject: [PATCH 3/3] fix for error fatal: The UID 1000 is already --- docker-entrypoint.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0e78868..143fed7 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -21,8 +21,16 @@ if ! id "$DOCKER_USER" >/dev/null 2>&1; then echo "Created group $DOCKER_GROUP with GID $GROUP_ID." fi - # Create user with the specified UID and associated group - adduser --shell /bin/sh --uid $USER_ID --ingroup $DOCKER_GROUP --disabled-password --gecos "" $DOCKER_USER + # Check if the desired USER_ID is already in use + if id -u $USER_ID >/dev/null 2>&1; then + EXISTING_USER=$(getent passwd $USER_ID | cut -d: -f1) + echo "UID $USER_ID is already in use by user $EXISTING_USER. Using this user." + DOCKER_USER=$EXISTING_USER + else + # Create user with the specified UID and associated group + adduser --shell /bin/sh --uid $USER_ID --ingroup $DOCKER_GROUP --disabled-password --gecos "" $DOCKER_USER + echo "Created user $DOCKER_USER with UID $USER_ID." + fi # Set ownership and permissions chown -vR $USER_ID:$GROUP_ID /opt/minecraft