Skip to content

Setting Kestrel port from environment variable #1208

@jocull

Description

@jocull

I'm using Dokku (like Heroku) to deploy an ASP.NET 5 Docker image, but I'm having trouble getting it to map the port properly.

  1. Dokku configures Nginx for you
  2. Dokku assigns a randomized web port that the Docker container should speak to
  3. The port to use is environment variable PORT = [randomized]

You can't set it manually, so there's no way to lock it to port 5000 (the default).

I tried changing the ENTRYPOINT in the Dockerfile to use substitution, but the ENTRYPOINT is not configured at runtime, so that is not possible.

I tried making a startup script instead:

#/bin/bash

dnx -p project.json web --server.urls http://0.0.0.0:${PORT}

Then in Dockerfile....

ENTRYPOINT ["/bin/bash", "./launch"]

However the port is STILL coming through as 5000. I have no idea why. How can I work around this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions