Skip to content

Commit

Permalink
fixes fatal: The GID `1000' is already in use.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoensing committed Aug 21, 2024
1 parent f7d441b commit 9996647
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

exec gosu $DOCKER_USER:$DOCKER_GROUP java -jar -Xms$MEMORYSIZE -Xmx$MEMORYSIZE $JAVAFLAGS /opt/minecraft/paperspigot.jar $PAPERMC_FLAGS nogui

0 comments on commit 9996647

Please sign in to comment.