Cannot Run ASP.NET 5 from Docker

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



Leave a reply



Submit