Skip to content

Commit 2d7809c

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

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ 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
24+
host: see [UID/GID mapping](uid-gid-mapping/) for details.
25+
2326
Rootless mode does not use binaries with `SETUID` bits or file capabilities,
2427
except `newuidmap` and `newgidmap`, which are needed to allow multiple
2528
UIDs/GIDs to be used in the user namespace.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
description: How container UIDs and GIDs are mapped to the host in rootless mode
3+
keywords: security, namespaces, rootless, uid, gid, subuid, subgid
4+
title: UID/GID mapping
5+
weight: 15
6+
---
7+
8+
Rootless mode and [`userns-remap` mode](../userns-remap.md) map container UIDs
9+
and GIDs to the host differently.
10+
11+
- In `userns-remap` mode, container UID `0` is mapped to the first subordinate
12+
UID listed in `/etc/subuid` for the remap user, and container UID `n` is
13+
mapped to `subuid + n`.
14+
- In rootless mode, container UID `0` is mapped to the host UID of the user
15+
running rootless Docker (the result of `id -u`); container UID `n` (for
16+
`n >= 1`) is mapped to `subuid + (n - 1)`.
17+
18+
GIDs follow the same rules using `/etc/subgid`.
19+
20+
This difference matters when setting file permissions on bind-mounted
21+
directories: in rootless mode, files owned by your host user appear as owned
22+
by `root` inside the container.

0 commit comments

Comments
 (0)