ScanSkill

USER

This, USER instruction is used to set the user name or UID to use when running the image for other instructions like CMD, RUN, and ENTRYPOINT instructions in Dockerfile. It can be optionally used to set the user group or GID also.

Syntax

USER <user>[:<group>]

OR

USER <UID>[:<GID>]

Note: If you don’t specify the user group, the default group root will be used. For windows, the user must be created first using net user command which is also part of Dockerfile.

Example

For the windows server, create a windows user in the container. In the case of a Linux container, there is no need for it.

FROM microsoft/windowsserver

# Create a windows user in the container... For Linux, you don't need to do this. 
RUN net user /add sagar

# Set user
USER sagar