From cf52512e20e06b21e79d70acdbf535481acffb8b Mon Sep 17 00:00:00 2001 From: clsferguson <48876201+clsferguson@users.noreply.github.com> Date: Mon, 22 Sep 2025 08:58:02 -0600 Subject: [PATCH] fix(docker): handle existing GID/UID 1000 in Ubuntu 24.04 base image Resolve Docker build failure when creating appuser with GID/UID 1000 The Ubuntu 24.04 CUDA base image already contains a user/group with GID 1000, causing the Docker build to fail with "groupadd: GID '1000' already exists". Changes made: - Add graceful handling for existing GID 1000 using `|| true` pattern - Add graceful handling for existing UID 1000 to prevent user creation conflicts - Ensure /home/appuser directory creation with explicit mkdir -p - Add explicit ownership assignment (chown 1000:1000) regardless of user creation outcome - Suppress stderr output from groupadd/useradd commands to reduce build noise This fix ensures the Docker build succeeds across different CUDA base image versions while maintaining the intended UID/GID mapping (1000:1000) required by the entrypoint script's permission management system. The container will now build successfully and the entrypoint script will still be able to perform proper user/group remapping at runtime via PUID/PGID environment variables as designed. Fixes build error: --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index bead0fbb7..05bc70e40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,9 +33,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && ln -sf /usr/bin/python3.12 /usr/bin/python3 \ && rm -rf /var/lib/apt/lists/* -# Create runtime user/group -RUN groupadd --gid 1000 appuser \ - && useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash appuser +# Create runtime user/group (handle existing GID/UID gracefully) +RUN (groupadd --gid 1000 appuser 2>/dev/null || true) \ + && (useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash appuser 2>/dev/null || true) \ + && mkdir -p /home/appuser \ + && chown -R 1000:1000 /home/appuser # Workdir WORKDIR /app/ComfyUI