mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-06 17:15:38 -08:00
1.9 KiB
Executable File
1.9 KiB
Executable File
Dev Ports in Host Network Mode
When using "--network=host" in the devcontainer, VS Code's normal port forwarding model doesn't apply. All container ports are already on the host network namespace, so:
- Listing ports in
forwardPortscan cause VS Code to pre-bind or reserve them (conflicts with startup scripts waiting for a free port). - The PORTS panel will not auto-detect services reliably, because forwarding isn't occurring.
- Debugger ports (e.g. Xdebug
9003, Python debugpy5678) can still be listed safely.
Recommended Pattern
- Only include debugger ports in
forwardPorts:"forwardPorts": [5678, 9003] - Do NOT list application service ports (e.g. 20211, 20212) there when in host mode.
- Use the helper task to enumerate current bindings:
- Run task:
> Tasks: Run Task→[Dev Container] List NetAlertX Ports
- Run task:
Port Enumeration Script
Script: scripts/list-ports.sh
Outputs binding address, PID (if resolvable) and process name for key ports.
You can edit the PORTS variable inside that script to add/remove watched ports.
Xdebug Notes
Set in 99-xdebug.ini:
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.discover_client_host=1
Ensure your IDE is listening on 9003.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Waiting for port 20211 to free... repeats |
VS Code pre-bound the port via forwardPorts |
Remove the port from forwardPorts, rebuild, retry |
| PHP request hangs at start | Xdebug trying to connect to unresolved host (host.docker.internal) |
Use 127.0.0.1 or rely on discovery |
| PORTS panel empty | Expected in host mode | Use the port enumeration task |
Future Improvements
- Optional: add a small web status endpoint summarizing runtime ports.
- Optional: detect host mode in
setup.shand skip the wait loop if the PID using port is the intended process.