Skip to content

Commit 4b91f5e

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

File tree

1 file changed

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

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ 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 `subuid + (n - 1)`.
31+
32+
GIDs follow the same rules using `/etc/subgid`.
33+
34+
This difference matters when setting file permissions on bind-mounted
35+
directories: in rootless mode, files owned by your host user appear as owned
36+
by `root` inside the container.
37+
2338
Rootless mode does not use binaries with `SETUID` bits or file capabilities,
2439
except `newuidmap` and `newgidmap`, which are needed to allow multiple
2540
UIDs/GIDs to be used in the user namespace.

0 commit comments

Comments
 (0)