Closed intermension closed 2 years ago
Your entrypoint should be
ENTRYPOINT ["dotnet", "webcore_docker.dll"]
--or--
ENTRYPOINT ["webcore_docker.exe"]
Based on the error message, I suspect webcore_docker.exe is not present, so I advise using the .dll entry point.
Both webcore_docker.exe and webcore_docker.dll are available in the image and changing the entry point to either doesn't affect the outcome. But again why is there any need to guess at it? Is it not as simple as
If (!File.Exists(entryPointPath)) { LogSpecificErrorMessage - Including the path it expected to use}
The resolution for this is inexplicable. This stack overflow article says that a Dockerized asp.net app cannot specify http://localhost:port. It must use http:*:port. Making this change in the web builder fixes the issue:
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); webBuilder.UseUrls("http://*:80"); });
I've not seen this documented anywhere and it seems well down stream from what the error messages were indicating but sample projects are now running in Docker.
@intermension the base image sets the environment variable ASPNETCORE_URLS to http://+:80, so unless you are overriding the defaults, it should just work. Also just to test, I tried overriding using "http://localhost:80" and I did not see the error you are reporting, I got the expected behavior or the app starting but not being reachable outside the container.
I'm still not sure what wasn't working for you, but I am glad that you were able to get unblocked.
Created an asp net core web app using a visual studio template. It works in debug mode/ docker mode from Visual Studio. But after successfully publishing to a docker repo and then pulling and running it, the container just exits straight away with the following error message:
This is the docker file:
` FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base WORKDIR /app EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build WORKDIR /src COPY ["source/source/webcore_docker/webcore_docker.csproj", "source/source/webcore_docker/"] RUN dotnet restore "source/source/webcore_docker/webcore_docker.csproj" COPY . . WORKDIR "/src/source/source/webcore_docker" RUN dotnet build "webcore_docker.csproj" -c Release -o /app/build
FROM build AS publish RUN dotnet publish "webcore_docker.csproj" -c Release -o /app/publish
FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "webcore_docker.exe"] ` These typically abysmal error messages from ms products don't help at all. Is there any reason why it just cant say what is wrong? Why is it some compounded series of potential things - nothing specific just a series of maybes? Can't the code just check if its the application that's missing OR if its an SDK issue, OR something else and communicate that specifically? How can the code not know why it cant run?