feat: bind to 127.0.0.1 by default instead of 0.0.0.0 (#2812)
* feat: bind to 127.0.0.1 by default instead of 0.0.0.0
Port bindings now default to localhost-only, preventing prediction
endpoints from being exposed to the entire network during development.
- Add HostIP field to command.Port struct (defaults to 127.0.0.1)
- Add --host flag to cog serve (default 127.0.0.1, use 0.0.0.0 to expose)
- Support host:port syntax in cog run -p (e.g. -p 0.0.0.0:8888)
- Bind cog predict/train to 127.0.0.1
- Update GetHostPortForContainer to match configured host IP
* docs: regenerate CLI and LLM docs for new --host flag
* fix: address review comments on localhost-by-default binding
- Restore host:port parsing for `cog exec -p` lost in the cog run→exec
rename; support plain ports, IPv4, bare and bracketed IPv6, with port
range and empty-host validation
- Extract shared command.DefaultHostIP constant (was duplicated)
- Narrow GetHostPortForContainer fallback to single wildcard/empty bindings
- Warn when serving via a remote Docker daemon; show a navigable localhost
URL alongside 0.0.0.0; bracket IPv6 display hosts
- Rename generic serve `host` var to `serveHost`
- Add unit tests for port binding helpers, host parsing, remote-host
detection, and serve URL formatting; make run_test table-driven
- Regenerate docs/cli.md and docs/llms.txt
---------
Co-authored-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Co-authored-by: asahoo <anishsahoo2005@gmail.com>