Skip to content

Commit 84a844f

Browse files
docs(cdk): Expand host-level configuration requirements in devlog
Co-Authored-By: Aaron <AJ> Steers <[email protected]>
1 parent 68b8364 commit 84a844f

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

devlog/2025-03-sandboxing-3.md

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,68 @@ The implementation now requires proper user namespace support to function, as th
6565

6666
## Production Deployment Requirements
6767

68-
For gVisor to work properly in production environments:
68+
For gVisor to work properly in production environments, several host-level configurations are required:
6969

70-
1. **Docker Runtime Configuration**: Configure the Docker daemon with user namespace remapping using the `userns-remap` option in `/etc/docker/daemon.json`:
70+
1. **Kernel Parameter Configuration**:
71+
72+
The `kernel.unprivileged_userns_clone` parameter controls whether unprivileged users can create user namespaces, which is essential for rootless containers:
73+
74+
```bash
75+
# Check if the parameter exists
76+
cat /proc/sys/kernel/unprivileged_userns_clone
77+
78+
# Enable unprivileged user namespaces (temporary)
79+
sysctl -w kernel.unprivileged_userns_clone=1
80+
81+
# Enable unprivileged user namespaces (persistent)
82+
echo 'kernel.unprivileged_userns_clone=1' > /etc/sysctl.d/userns.conf
83+
```
84+
85+
This parameter is not available on all systems. Some distributions like Ubuntu have it enabled by default, while others may require kernel recompilation or may not support it at all.
86+
87+
2. **Docker Daemon Configuration**:
88+
89+
The Docker daemon needs to be configured to support user namespace remapping using the `userns-remap` option in `/etc/docker/daemon.json`:
90+
7191
```json
7292
{
7393
"userns-remap": "default"
7494
}
7595
```
96+
97+
This configuration maps the root user inside the container to a non-root user on the host, providing an additional layer of security. The "default" value creates a user and group named "dockremap" for this purpose.
98+
99+
After modifying this file, restart the Docker daemon:
100+
101+
```bash
102+
systemctl restart docker
103+
```
104+
105+
Note that enabling user namespace remapping affects all containers and may require additional configuration for volume mounts and other Docker features.
76106

77-
2. **Host-Level Configuration**: Enable user namespaces at the host level:
107+
3. **User Namespace Mapping Tools**:
108+
109+
The `newuidmap` and `newgidmap` tools are required for mapping user and group IDs between the container and the host. These tools are typically provided by the `uidmap` package:
110+
78111
```bash
79-
echo 'kernel.unprivileged_userns_clone=1' > /etc/sysctl.d/userns.conf
80-
sysctl -w kernel.unprivileged_userns_clone=1
112+
# Install on Debian/Ubuntu
113+
apt-get install -y uidmap
114+
115+
# Install on CentOS/RHEL
116+
yum install -y shadow-utils
81117
```
118+
119+
These tools are used by the container runtime to set up the user namespace mappings when a container is started. Without them, you'll see errors like `newuidmap failed: exit status 1` when attempting to use user namespaces.
82120

83-
3. **Container Runtime Flags**: Run containers with the appropriate flags:
121+
4. **Container Runtime Flags**:
122+
123+
When running containers, use the appropriate flags to enable user namespace support and disable security features that might interfere with gVisor:
124+
84125
```bash
85126
docker run --security-opt seccomp=unconfined --security-opt apparmor=unconfined --userns=host
86127
```
128+
129+
These flags disable the seccomp and AppArmor security profiles, which might otherwise interfere with gVisor's operation, and enable host user namespace support.
87130

88131
## Testing Limitations
89132

0 commit comments

Comments
 (0)