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