Docker: Change dotnet core default listening port
Date: 2021-01-25 | csharp | docker | dotnet-core |
DISCLOSURE: If you buy through affiliate links, I may earn a small commission. (disclosures)
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"
}
Want more like this?
The best way to support my work is to like / comment / share for the algorithm and subscribe for future updates.