Search code examples
windowsdockerasp.net-coredocker-desktop

ASP.NET Core website not running in docker even though container appears to be running


This is my first docker try. I am using Windows 10, installed Docker Desktop and using Windows containers. I have created a simple hello world type asp.net core web application in VS Code and trying to run it in docker.

I wrote code in VS Code then published it in folder /bin/Publish. Then inside Publish folder I created Dockerfile as follows:

FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-windowsservercore-ltsc2019  
COPY . /inetpub/wwwroot

After that image was downloaded which can be seen in below screenshot. First image naziacore is the one I am trying to run.

enter image description here

Then I ran docker using following command:

docker run -i -d -p 80:80 naziacore

But when I open browser and type http://localhost then website doesn't open. It shows that standard error like website is down or you don't have internet connection.

Running following command shows that container is running.

enter image description here

I can see that files have been copied to inetpub/wwwroot

enter image description here

I even tried a different port but no luck. How to diagnose and fix this issue?


Solution

  • Looks like you are missing some parts of your dockerfile. I'd recommend you check out this, but I think adding an entrypoint to the end is what you probably need:

    WORKDIR /inetpub/wwwroot
    ENTRYPOINT ["dotnet", "NaziaDocker.dll"]