Skip to content

Commit d46d9de

Browse files
committed
engine/security/rootless/troubleshoot: update "Network is slow"
- VPNKit is no longer installed - `docker run --net=host` is available since v29.5 - Add `lxc-user-nic` hints Follow-up to PR 24645 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
1 parent 9d2f06b commit d46d9de

1 file changed

Lines changed: 45 additions & 11 deletions

File tree

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

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -290,25 +290,59 @@ network namespace. Use `docker run -p` instead, or upgrade to Docker Engine v29.
290290

291291
#### Network is slow
292292

293-
Docker with rootless mode uses [slirp4netns](https://github.com/rootless-containers/slirp4netns) as the default network stack if slirp4netns v0.4.0 or later is installed.
294-
If slirp4netns is not installed, Docker falls back to [VPNKit](https://github.com/moby/vpnkit).
295-
Installing slirp4netns may improve the network throughput.
293+
Docker with rootless mode uses a TCP/IP stack running in user mode, such as:
294+
- [slirp4netns](https://github.com/rootless-containers/slirp4netns) (default when slirp4netns is installed)
295+
- [pasta](https://passt.top/passt/about/)
296+
- [VPNKit](https://github.com/moby/vpnkit)
297+
- [gvisor-tap-vsock](https://github.com/containers/gvisor-tap-vsock) (default when none of the above is installed)
296298

297-
For more information about network drivers for RootlessKit, see
298-
[RootlessKit documentation](https://github.com/rootless-containers/rootlesskit/blob/v3.0.0/docs/network.md).
299+
The TCP/IP stack in user mode is generally slower than the one in kernel mode, and the performance may vary depending on the network driver used.
299300

300-
Also, changing MTU value may improve the throughput.
301-
The MTU value can be specified by creating `~/.config/systemd/user/docker.service.d/override.conf` with the following content:
301+
See [RootlessKit documentation](https://github.com/rootless-containers/rootlesskit/blob/v3.0.0/docs/network.md)
302+
for more information.
303+
304+
##### Workaround 1: bypass user-mode TCP/IP stack
305+
306+
Use `docker run --net=host` to bypass the user-mode TCP/IP stack.
307+
This is applicable since Docker Engine v29.5.
308+
However, this requires the container to share the host network namespace, which may not be desirable for security reasons.
309+
310+
##### Workaround 2: disable user-mode TCP/IP stack
311+
312+
Alternatively, you can use the `lxc-user-nic` network driver (experimental) to disable the user-mode TCP/IP stack entirely.
313+
However, this requires configuring `/etc/lxc/lxc-usernet` for enabling the privileged helper.
314+
315+
```bash
316+
sudo apt-get install -y lxc
317+
sudo mkdir -p /etc/lxc
318+
cat <<EOF | sudo tee /etc/lxc/lxc-usernet
319+
# USERNAME TYPE BRIDGE COUNT
320+
$USER veth lxcbr0 10
321+
EOF
322+
```
323+
324+
Also, make sure that the rootful daemon is not running, as its iptables rules may interfere with the `lxc-user-nic` driver.
325+
```console
326+
$ systemctl is-active docker.service
327+
inactive
328+
329+
$ systemctl is-active docker.socket
330+
inactive
331+
```
332+
333+
The network driver can be specified by creating `~/.config/systemd/user/docker.service.d/override.conf` with the following content:
302334

303335
```systemd
304336
[Service]
305-
Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_MTU=<INTEGER>"
337+
Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_NET=lxc-user-nic"
338+
# Optional: specify MTU (may affect throughput)
339+
# Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_MTU=<INTEGER>"
306340
```
307341

308342
And then restart the daemon:
309-
```console
310-
$ systemctl --user daemon-reload
311-
$ systemctl --user restart docker
343+
```bash
344+
systemctl --user daemon-reload
345+
systemctl --user restart docker
312346
```
313347

314348
#### `docker run -p` does not propagate source IP addresses

0 commit comments

Comments
 (0)