Plain .NET 5 project runs in Docker but doesn't reacts to requests
It listens on port 80 in the container because Microsoft set the ASPNETCORE_URLS environment variable in their aspnet Docker images to http://+:80
which overrides your configuration.
To get it to listen on something else, you have to set the ASPNETCORE_URLS variable yourself in your Dockerfile.
To get it to listen on port 5000 and 5001 like you want, you need to add
ENV ASPNETCORE_URLS=http://+:5000;https://+:5001
to your Dockerfile
They set it in the runtime-deps
image, which is the base for the runtime
image, which is the base for the aspnet
image. You can see it here: https://github.com/dotnet/dotnet-docker/blob/d8dc00685a45b7f534e9f68ded50667023ded151/src/runtime-deps/3.1/bullseye-slim/amd64/Dockerfile
why dotnet 5 docker container fail in run time?
Use this as your base image:
FROM mcr.microsoft.com/dotnet/aspnet:5.0.0-buster-slim AS base
Related Topics
How to Load a .Net Assembly At Runtime and Instantiate a Type Knowing Only the Name
How to Access Random Item in List
Is Floating-Point Math Consistent in C#? Can It Be
Using C#, How Does One Figure Out What Process Locked a File
C# 3.0 Auto-Properties - Useful or Not
Is There a Good Linq Way to Do a Cartesian Product
Plain Old Clr Object VS Data Transfer Object
Using Async/Await For Multiple Tasks
What Is App.Config in C#.Net - How to Use It
Why Is Dictionary Preferred Over Hashtable in C#
Setting Authorization Header of Httpclient