-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Set $PORT for containers #2258
Copy link
Copy link
Closed
Labels
area/APIAPI objects and controllersAPI objects and controllersarea/networkingkind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.kind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.Categorizes issue or PR as related to cleaning up code, process, or technical debt.kind/specDiscussion of how a feature should be exposed to customers.Discussion of how a feature should be exposed to customers.
Milestone
Metadata
Metadata
Assignees
Labels
area/APIAPI objects and controllersAPI objects and controllersarea/networkingkind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.kind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.Categorizes issue or PR as related to cleaning up code, process, or technical debt.kind/specDiscussion of how a feature should be exposed to customers.Discussion of how a feature should be exposed to customers.
(Copied from an earlier discussion about 2 months ago which didn't make it into an issue somehow.)
Our runtime spec says that the $PORT environment variable WILL indicate which port the environment will attempt to connect the container on. Ideally, all our customers would read our documentation and consume $PORT without needing any external assistance (flags, config, etc).
Unfortunately, our users are in as much of a rush as we are, so we should try to choose our defaults so that the maximum number of cases just work. Based on our experience, we default the
containerPortto 8080 if unset, to catch the common use case. In some other cases, the container may expose a flag which allows the user to choose which port to run the server on. The user can set this flag in their configuration to$PORTto get the same behavior as our ideal, with the cost of one extra command-line flag.In other cases, the built container may expose some other port which is hard-coded; if we are able to parse the metadata, we could extract the port from the EXPOSE command. If all of these fail, the customer should be able to set
container.ports[0].containerPortto the hard-coded port in their docker image.Expected Behavior
The PORT environment variable is set based on our best determination for the
containerPort:EXPOSEmetadata from image.Actual Behavior
We always assume 8080.
See also #2101, which is a slightly different issue about our ability to consume the reasonable value for
containerPort.