Skip to content

Commit 162c03b

Browse files
committed
docs: clarify subuid/subgid mapping in rootless vs userns-remap
1 parent f904090 commit 162c03b

File tree

1 file changed

+14
-0
lines changed
  • content/manuals/engine/security/rootless

1 file changed

+14
-0
lines changed

content/manuals/engine/security/rootless/_index.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ with `userns-remap` mode, the daemon itself is running with root privileges,
2020
whereas in rootless mode, both the daemon and the container are running without
2121
root privileges.
2222

23+
The two modes also differ in how they map container UIDs and GIDs to the host:
24+
25+
- In `userns-remap` mode, container UID `0` is mapped to the first subordinate
26+
UID listed in `/etc/subuid` for the remap user, and container UID `n` is
27+
mapped to `subuid + n`.
28+
- In rootless mode, container UID `0` is mapped to the host UID of the user
29+
running rootless Docker (the result of `id -u`); container UID `n` (for
30+
`n >= 1`) is mapped to the `n`-th subordinate UID listed in `/etc/subuid`
31+
(so UID `1` is the first subuid, UID `2` is the second, and so on).
32+
33+
This difference matters when setting file permissions on bind-mounted
34+
directories: in rootless mode, files owned by your host user appear as owned
35+
by `root` inside the container.
36+
2337
Rootless mode does not use binaries with `SETUID` bits or file capabilities,
2438
except `newuidmap` and `newgidmap`, which are needed to allow multiple
2539
UIDs/GIDs to be used in the user namespace.

0 commit comments

Comments
 (0)