ITADN

Unable to set user in glibc-dynamic derived image

#3008Closedadamretter 创建于 2025-08-24
A
adamrettercommented
Hi there, I am trying to add a user account to the `glibc-dynamic` image so that I can run my application under a a non-root account. I would like to have a dedicated system account with low privileges for my application. As there is no `adduser or addgroup` commands, I try and do this in a builder stage, and then copy over the relevant linux /etc files to the glibc-dynamic derived stage. My Dockerfile looks something like this: ``` FROM cgr.dev/chainguard/wolfi-base AS builder ARG ELEMENTAL_SERVER_SERVICE_ACCOUNT="edb01" ARG ELEMENTAL_SERVER_SERVICE_GROUP="edb01" # Add Elemental Server service group and account RUN addgroup -S edb01 \ && adduser -S -G edb01 -H -h /nonexistent -s /sbin/nologin edb01 FROM cgr.dev/chainguard/glibc-dynamic:latest # Copy Elemental Server service group and account COPY --from=builder --chown=root:root --chmod=0644 /etc/passwd /etc/passwd COPY --from=builder --chown=root:root --chmod=0644 /etc/group /etc/group COPY --from=builder --chown=root:root --chmod=0600 /etc/shadow /etc/shadow USER edb01 ADD --chown=edb01:edb01 --chmod=0755 my-application /my-application ENTRYPOINT [ "/my-application"] ``` Unfortunately when my application runs, it is running under the `root` account and NOT the `edb01` account. However, if I change `USER edb01` to `USER nonroot` then my application runs under the `nonroot` account. Please can you tell me why my application doesn't run under the `edb01` account as instructed in the Dockerfile? This seems perhaps specific to the `glibc-dynamic` image.
关闭于 2025-08-28 1 条评论