From 1d57588d2795c981c31ac82c54f3f4155dcc7d82 Mon Sep 17 00:00:00 2001 From: ViperEkura <3081035982@qq.com> Date: Wed, 26 Aug 2026 15:00:15 +0800 Subject: [PATCH] fix: free default ubuntu uid/gid before creating astrai user - ubuntu:24.04 base image ships a default 'ubuntu' user/group at uid/gid 1000, so the default USER_UID/USER_GID build args collided and docker build failed at groupadd with "GID '1000' already exists" - remove the default ubuntu user/group first (tolerating images without it) so the astrai non-root user is created with the host uid/gid as intended --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9cac362..b3fc1bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,10 +57,14 @@ COPY docs/ ./docs/ COPY pyproject.toml . COPY README.md . -# Create non-root user matching the host uid/gid (passed via build args) +# Create non-root user matching the host uid/gid (passed via build args). +# ubuntu:24.04 ships a default 'ubuntu' user/group at uid/gid 1000, so remove +# it first to free those ids before creating astrai. ARG USER_UID=1000 ARG USER_GID=1000 -RUN groupadd -g "${USER_GID}" astrai \ +RUN userdel -r ubuntu 2>/dev/null || true \ + && groupdel ubuntu 2>/dev/null || true \ + && groupadd -g "${USER_GID}" astrai \ && useradd -m -u "${USER_UID}" -g astrai astrai \ && chown -R astrai:astrai /app ENV HOME=/home/astrai