docs(docker): run as root under host networking to bind port 79

Host networking shares the host net namespace, so the host's
privileged-port rule applies and the image's non-root user cannot bind 79
-- the daemon fails to listen silently. Add user: "0:0" to the compose and
correct the earlier (wrong) claim that non-root bind still works. Note
setcap as the non-root alternative.
This commit is contained in:
pmb
2026-06-15 16:54:47 -07:00
parent 011f8c4838
commit b1e7f5229b
2 changed files with 16 additions and 5 deletions
+9 -3
View File
@@ -83,15 +83,21 @@ client IP. In order of preference:
1. **Host networking (recommended).** Add `network_mode: host` to the service 1. **Host networking (recommended).** Add `network_mode: host` to the service
(and drop the `ports:` mapping -- it's ignored). The daemon then binds the (and drop the `ports:` mapping -- it's ignored). The daemon then binds the
host's port 79 directly and sees real client IPs. Non-root bind of port 79 host's port 79 directly and sees real client IPs. This is what
still works because Docker grants `CAP_NET_BIND_SERVICE` by default. This is `docker-compose.yml` in this repo uses.
what `docker-compose.yml` in this repo now uses.
Note: under host networking the container shares the host network namespace,
which uses the host's privileged-port rule -- so the image's non-root user
(UID 1000) **cannot bind port 79** and the daemon fails to listen silently.
Either run as root (`user: "0:0"`, as below) or `setcap
cap_net_bind_service=+ep` on the binary in the image to keep it non-root.
```yaml ```yaml
services: services:
finger: finger:
image: ghcr.io/waffle2k/finger:latest image: ghcr.io/waffle2k/finger:latest
network_mode: host network_mode: host
user: "0:0" # bind privileged port 79 under host networking
volumes: volumes:
- ./users:/var/finger/users - ./users:/var/finger/users
restart: unless-stopped restart: unless-stopped
+7 -2
View File
@@ -9,9 +9,14 @@ services:
# single source IP for everyone -- the per-IP ban logic can't tell clients # single source IP for everyone -- the per-IP ban logic can't tell clients
# apart and (by design) treats that private address as untrackable, leaving # apart and (by design) treats that private address as untrackable, leaving
# banning inert. Host networking exposes the real client IP, so repeat # banning inert. Host networking exposes the real client IP, so repeat
# offenders actually get blocked. (Non-root bind of port 79 still works: # offenders actually get blocked.
# Docker grants CAP_NET_BIND_SERVICE by default.)
network_mode: host network_mode: host
# Under host networking the container shares the host net namespace, which
# uses the host's privileged-port rule -- so the image's non-root user
# (UID 1000) cannot bind port 79 and the daemon fails to listen silently.
# Run as root to bind it. (Alternative: setcap cap_net_bind_service on the
# binary in the image to keep it non-root.)
user: "0:0"
volumes: volumes:
- ./users:/var/finger/users - ./users:/var/finger/users
restart: unless-stopped restart: unless-stopped