feat: bind to 127.0.0.1 by default instead of 0.0.0.0#2812
Conversation
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
|
LGTM |
|
@anish-sahoo Bonk workflow was cancelled. View workflow run · To retry, trigger Bonk again. |
|
Changes default port binding from Issues found:
|
|
I'm Bonk, and I've done a quick review of your PR. Summary: Changes default Docker port binding from Issues (highest severity first):
I posted the full review as a top-level PR comment because the batch review API returned a 422 (likely stale line numbers). You can view it here: #2812 (comment) |
Summary
0.0.0.0to127.0.0.1across all commands, preventing prediction endpoints from being accidentally exposed to the entire network during development.--hostflag tocog serveandhost:portsyntax tocog run -pso users can opt into binding to all interfaces when needed.Changes
pkg/docker/command/command.goHostIPfield toPortstructpkg/docker/docker.goport.HostIP(default127.0.0.1) instead of hardcoded""pkg/docker/run.goGetHostPortForContainernow accepts ahostIPparameterpkg/docker/run_test.gopkg/cli/serve.go--hostflag (default127.0.0.1)pkg/cli/run.go-pflag supportshost:portsyntax (e.g.-p 0.0.0.0:8888), defaults to127.0.0.1pkg/predict/predictor.gocog predict/cog trainbind to127.0.0.1User-facing behavior
cog serve0.0.0.0127.0.0.1. Use--host 0.0.0.0to expose.cog run -p 88880.0.0.0:8888127.0.0.1:8888. Use-p 0.0.0.0:8888to expose.cog predict/cog train0.0.0.0127.0.0.1Test plan