Dockerfile instructions
Dockerfile USER
Sets the identity for later RUN and the default runtime process. Linux accepts numeric UID/GID. Prepare appropriate ownership first. Does not change engine privilege. Record the actual numeric UID and GID; a runtime override is possible and rootless Engine is a different concept.
Formal Syntax & Structure
docker syntaxdocker
USER <user>[:<group>]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| user | string | User name or numeric UID. |
| group | string | Optional group name or GID. |
Working Example
Example Snippetdocker
FROM busybox:1.37RUN mkdir /app && chown 10001:10001 /appUSER 10001:10001WORKDIR /appRUN printf "prepared\n" > note.txtCMD ["sh", "-c", "id -u; id -g; cat note.txt"]