Skip to content

Commit df3ca50

Browse files
author
Meatloaf Bot
committed
Address CodeRabbit review: Clarify sysctl behavior in host network mode
1 parent 93fc126 commit df3ca50

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

docs/DOCKER_COMPOSE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ services:
3131
- SETUID # Required for root-entrypoint to switch to non-root user
3232
- SETGID # Required for root-entrypoint to switch to non-root group
3333
# --- ARP FLUX MITIGATION ---
34-
# Note: If running in `network_mode: host`, modern Docker/runc will correctly
35-
# block sysctl overrides via the container configuration to prevent
36-
# unauthorized changes to the host's global kernel settings.
34+
# Note: When using `network_mode: host`, these sysctls require the
35+
# NET_ADMIN capability to be applied to the host namespace.
3736
#
38-
# If using host networking, REMOVE the sysctls block below and apply
39-
# settings directly on your Host OS instead (sudo sysctl -w ...).
37+
# If your environment restricts capabilities, or you prefer to configure
38+
# them on the Host OS, REMOVE the sysctls block below and apply via:
39+
# sudo sysctl -w net.ipv4.conf.all.arp_ignore=1 net.ipv4.conf.all.arp_announce=2
4040
# ---------------------------
4141
sysctls: # ARP flux mitigation (reduces duplicate/ambiguous ARP behavior on host networking)
4242
net.ipv4.conf.all.arp_ignore: 1

docs/docker-troubleshooting/arp-flux-sysctls.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ The running environment does not provide the expected kernel sysctl values. This
2121

2222
## How to Correct the Issue
2323

24-
### Option A: Via Docker (Standard Bridge Networking)
24+
### Option A: Via Docker (Standard Bridge Networking or `network_mode: host` with `NET_ADMIN`)
2525

26-
If you are using standard bridged networking (default), set these sysctls at container runtime.
26+
If you are using standard bridged networking, or `network_mode: host` and the container is granted the `NET_ADMIN` capability (as is the default recommendation), set these sysctls at container runtime.
2727

2828
- In `docker-compose.yml` (preferred):
2929
```yaml
@@ -46,9 +46,9 @@ If you are using standard bridged networking (default), set these sysctls at con
4646
> - Use `--privileged` with `docker run`.
4747
> - Use the more restrictive `--cap-add=NET_ADMIN` (or `cap_add: [NET_ADMIN]` in `docker-compose` service definitions) to allow the sysctls to be applied at runtime.
4848

49-
### Option B: Via Host OS (Required for `network_mode: host`)
49+
### Option B: Via Host OS (Fallback for `network_mode: host`)
5050

51-
If you are running the container with `network_mode: host`, modern Docker versions (specifically the `runc` runtime) **will not allow** you to set `net.*` sysctls via the container configuration. Attempting to do so will result in an OCI runtime error: `sysctl "net.ipv4.conf.all.arp_announce" not allowed in host network namespace`.
51+
If you are running the container with `network_mode: host` and cannot grant the `NET_ADMIN` capability, or if your container runtime environment explicitly blocks sysctl overrides, applying these settings via the container configuration will fail. Attempting to do so without sufficient privileges typically results in an OCI runtime error: `sysctl "net.ipv4.conf.all.arp_announce" not allowed in host network namespace`.
5252

5353
In this scenario, you must apply the settings directly on your host operating system:
5454

install/production-filesystem/entrypoint.d/37-host-optimization.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ if [ "$failed" -eq 1 ]; then
2222
net.ipv4.conf.all.arp_ignore=1
2323
net.ipv4.conf.all.arp_announce=2
2424
25-
Note: If using 'network_mode: host', you cannot set these via docker-compose
26-
sysctls. You must configure them directly on your host operating system instead.
25+
Note: If using 'network_mode: host', setting these via docker-compose sysctls
26+
requires the NET_ADMIN capability. When granted, these sysctls will
27+
modify the host namespace. Otherwise, you must configure them directly
28+
on your host operating system instead.
2729
2830
Detection accuracy may be reduced until configured.
2931

0 commit comments

Comments
 (0)