Skip to content

Proposal: Expose an environment variable for port bindings inside the container #7421

@capoferro

Description

@capoferro

Our applications register themselves with service discovery upon startup. Currently, we have to statically define the port bindings on docker run via -p 1234:45000 and then provide the port via an environment variable (-e HOST_PORT:45000) so the app can correctly register itself correctly.

It would be helpful to have that environment variable exposed inside the container automatically to indicate which port docker has selected for our container so we can rely on docker port allocation instead of having to rewrite port allocation as part of a tool external to docker.

It's likely that a container binds to many ports, so the envvars exposed should follow a scheme similar to how container link envvars are generated. In the above example (-p 1234:45000), the env var generated would be something like HOST_PORT_1234.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shiny

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions