×
☰ See All Chapters

Docker USER command

To consider the users other than root and users with sudo access to be able to run Docker commands, the USER command should be specified with username to be used when a command is run. By default, the containers will be launched with root as the user ID or UID. The USER command sets the startup user ID or user Name in the new image.

Docker USER Command Syntax

USER <UserID>

OR

USER <UserName>

<UserID>: User ID

<UserName>: User Name

User command can set either User ID or valid User Name.

Docker USER Command Example

USER 10

USER manum

The USER command can be used on the RUN command, the CMD command, or the ENTRYPOINT command in the Dockerfile.  User defined in the USER command should exist and should have necessary permissions otherwise your image will fail to build.

 

 


All Chapters
Author