Docker: Change dotnet core default listening port

2021.01.25 | 111 words |

Overview

I’m using Google App Engine to host my dockerized dotnet core app. App Engine expects all communications to go through port 8080 so I need to change the port my app is listening on. How do I do that?

Solution

There are several ways to go about this as laid out in 5 ways to set the URLs for an ASP.NET Core app however I was only able to get one to work successfully.

That one is to add a Urls node inside the appsettings.json.

Here’s an example of it in action:

{
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "Urls": "http://host.docker.internal:8080"
}
 

About the Ham

Hi I'm Hamilton - I built this! If you want more content like this subscribe to my email list, connect with me around the web, or take a look at some of my other projects.

More Projects

comments powered by Disqus