Skip to content

Commit 2d4ef46

Browse files
committed
docs: move UID/GID mapping details to a subpage
Addresses review feedback asking to keep _index.md concise.
1 parent 4b91f5e commit 2d4ef46

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

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

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,16 @@ 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.
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.
3725

3826
Rootless mode does not use binaries with `SETUID` bits or file capabilities,
3927
except `newuidmap` and `newgidmap`, which are needed to allow multiple
4028
UIDs/GIDs to be used in the user namespace.
4129

42-
4330
## Prerequisites
4431

45-
- You must install `newuidmap` and `newgidmap` on the host. These commands
32+
- You must install `newuidmap` and `newgidmap` on the host. These commands
4633
are provided by the `uidmap` package on most distributions.
4734

4835
- `/etc/subuid` and `/etc/subgid` should contain at least 65,536 subordinate
@@ -68,13 +55,15 @@ when the prerequisites are not satisfied.
6855
> [!NOTE]
6956
>
7057
> If the system-wide Docker daemon is already running, consider disabling it:
71-
>```console
72-
>$ sudo systemctl disable --now docker.service docker.socket
73-
>$ sudo rm /var/run/docker.sock
74-
>```
58+
>
59+
> ```console
60+
> $ sudo systemctl disable --now docker.service docker.socket
61+
> $ sudo rm /var/run/docker.sock
62+
> ```
63+
>
7564
> Should you choose not to shut down the `docker` service and socket, you will need to use the `--force`
7665
> parameter in the next section. There are no known issues, but until you shutdown and disable you're
77-
> still running rootful Docker.
66+
> still running rootful Docker.
7867
7968
{{< tabs >}}
8069
{{< tab name="With packages (RPM/DEB)" >}}
@@ -143,6 +132,7 @@ The binaries will be installed at `~/bin`.
143132
{{< /tabs >}}
144133

145134
Run `docker info` to confirm that the `docker` client is connecting to the Rootless daemon:
135+
146136
```console
147137
$ docker info
148138
Client: Docker Engine - Community
@@ -159,4 +149,4 @@ Server:
159149
...
160150
```
161151

162-
See [Troubleshooting](./troubleshoot.md) if you faced an error.
152+
See [Troubleshooting](./troubleshoot.md) if you faced an error.
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)