[WIP - test needed] docker: switch node to host networking on Linux (fix #18)#19
Open
shayanb wants to merge 1 commit into
Open
[WIP - test needed] docker: switch node to host networking on Linux (fix #18)#19shayanb wants to merge 1 commit into
shayanb wants to merge 1 commit into
Conversation
ufw-docker installs a DOCKER-USER rule that drops inbound UDP to container
IPs on dport ≤32767. The node's QUIC socket reuses port 3000 for listen +
dial, so peer replies come back on dport 3000 and get dropped → every
handshake times out, node stuck at height 0.
Host networking sidesteps the DOCKER-USER chain entirely (host-net containers
flow through INPUT/OUTPUT, not FORWARD). Linux installs now default to
`network_mode: host`; Mac/Docker Desktop stays on bridge.
- New LOGOS_DOCKER_NETWORK_MODE setting in settings.env. Default = host on
Linux, bridge elsewhere. Operators with custom ports or unexpected
host-net problems can opt back to bridge.
- Monitoring stack stays on bridge: exporter reaches the node via
host.docker.internal:${LOGOS_API_PORT} + extra_hosts host-gateway;
logos-otel publishes 4317 on loopback only so the node can push OTLP.
- migrate_user_config_otlp_endpoint rewrites the OTLP endpoint on update
so 0.4.3 installs going to host mode get http://logos-otel:4317 →
http://127.0.0.1:4317 automatically. Idempotent; leaves custom
endpoints alone.
- cmd_start drift check now also triggers on network-mode mismatch.
- Warn at every compose-regen site when custom LOGOS_API_PORT /
LOGOS_UDP_PORT are set under host mode (they no longer apply), and
point at the escape hatch.
- New security scan finding flags ufw-docker presence when the bridged
monitoring stack is installed — Grafana LAN access still needs an
explicit `ufw-docker allow logos-grafana 3000/tcp`.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #18 —
ufw-dockerinstalls aDOCKER-USERrule that drops inbound UDP to container IPs ondport ≤32767. The node's QUIC socket reuses port 3000 for listen + dial, so peer replies come back ondport 3000and get dropped → every handshake times out, node stuck at height 0.Host networking sidesteps the entire
DOCKER-USERchain (host-net containers flow throughINPUT/OUTPUT, notFORWARD). Linux installs now default tonetwork_mode: host; macOS / Docker Desktop stays on bridge.Changes
LOGOS_DOCKER_NETWORK_MODEsetting added tosettings.env. Default =hoston Linux,bridgeelsewhere. Escape hatch for operators with custom ports or unexpected host-net edge cases.lib/docker.sh) —generate_compose_file()now emits two distinct shapes: under host mode it dropsports:/networks:and addsnetwork_mode: host; bridge mode is byte-equivalent to 0.4.3.lib/monitoring.sh) — stays on the bridge. Under host mode the exporter points athost.docker.internal:${LOGOS_API_PORT}withextra_hosts: host-gateway;logos-otelpublishes127.0.0.1:4317:4317so the host-net node can push OTLP via loopback (never exposed to the LAN).migrate_user_config_otlp_endpointhelper rewritesendpoint: "http://logos-otel:4317"↔http://127.0.0.1:4317onlogosup updateso 0.4.3 installs going to host mode get migrated automatically. Idempotent; leaves operator-customized endpoints alone; no-op when the metrics block is absent.cmd_start.sh) — regen triggers on network-mode mismatch in addition to port drift, with a defensivemigrate_user_config_otlp_endpointcall after any regen.LOGOS_API_PORT≠8080orLOGOS_UDP_PORT≠3000under host mode (they're ignored because Docker port mapping no longer applies) and point at the escape hatch._check_ufw_dockerfinding (Linux-only) flags ufw-docker presence when the bridged monitoring stack is installed. Grafana LAN access still needs an explicitsudo ufw-docker allow logos-grafana 3000/tcp— the finding surfaces that command.VERSION→ 0.4.4.Local verification done
bash -non all eight modified files: clean.python3 yaml.safe_load).docker compose config --quietexits 0 for both node and monitoring compose, under both modes.host + custom, silent in all other combinations.Test plan (real hardware — not yet done)
logosup installon a clean box. Verifynetwork_mode: hostindocker-compose.yml, noports:/networks:block.docker inspect logos-node --format '{{.HostConfig.NetworkMode}}'returnshost.ss -lnup | grep :3000shows the node listening on host UDP 3000 directly.logosup update cli && logosup update node. Verifyuser_config.yamlendpoint rewrote fromlogos-otel:4317to127.0.0.1:4317, compose recreated with host mode, container hasNetworkMode=host. Chain DB and wallet keys untouched.echo 'LOGOS_DOCKER_NETWORK_MODE=bridge' >> settings.env && logosup stop && logosup start. Compose regenerates withports:andnetworks:, OTLP endpoint reverts tologos-otel:4317./cryptarchia/info,/network/info), prometheus scrapes are green, Grafana dashboard shows live data, node-side OTLP push lands in the otel collector.bridge. Compose is byte-equivalent to 0.4.3 (modulo whitespace from the heredoc refactor).ufw-dockerrules +docker-compose.monitoring.yml, confirm the new warn finding appears with theufw-docker allowcommand. Without ufw-docker → no finding. Without monitoring compose → no finding.LOGOS_API_PORT=9000+ Linux +logosup update node→ warn message visible, points at escape hatch.Edge cases noted
slirp4netns; no code change, mention in release notes.cmd_start.shhealth_rc=2branch already catches this and surfaces logs.docker_repair_unmanaged_network— under host mode the node is no longer attached tologosnode-net, but the monitoring stack still owns it. Repair logic operates on labels and works fine; verified during planning.Planning notes:
/Users/shayan/.claude/plans/crystalline-growing-flame.md🤖 Generated with Claude Code