docs: rewrite section on setting user id

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2023-11-27 21:51:02 +01:00
parent 259aa90059
commit 4a84514552
1 changed files with 15 additions and 11 deletions

View File

@ -1207,21 +1207,25 @@ The health status is also displayed in the `docker ps` output.
### User ### User
`root` (id = 0) is the default user within a container. The image developer can The default user within a container is `root` (id = 0). You can set a default
create additional users. Those users are accessible by name. When passing a numeric user to run the first process with the Dockerfile `USER` instruction. When
ID, the user does not have to exist in the container. starting a container, you can override the `USER` instruction by passing the
`-u` option.
The developer can set a default user to run the first process with the ```text
Dockerfile `USER` instruction. When starting a container, the operator can override -u="", --user="": Sets the username or UID used and optionally the groupname or GID for the specified command.
the `USER` instruction by passing the `-u` option. ```
-u="", --user="": Sets the username or UID used and optionally the groupname or GID for the specified command. The followings examples are all valid:
The followings examples are all valid: ```text
--user=[ user | user:group | uid | uid:gid | user:gid | uid:group ] --user=[ user | user:group | uid | uid:gid | user:gid | uid:group ]
```
> **Note:** if you pass a numeric uid, it must be in the range of 0-2147483647. > **Note**
> If you pass a username, the user must exist in the container. >
> If you pass a numeric user ID, it must be in the range of 0-2147483647. If
> you pass a username, the user must exist in the container.
### Working directory ### Working directory