Skip to content

Commit

Permalink
fix for error fatal: The UID 1000 is already
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoensing committed Aug 22, 2024
1 parent a4795c8 commit b6d0f04
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b6d0f04

Please sign in to comment.