locked
Difference in running Asp.net Core app in docker vs iis RRS feed

  • Question

  • User-1045336983 posted

    I just created a sample api project and ran it inside of a container using docker commands and even created a custom image of the sample app. I am a beginner and am a bit confused right now as how is my app running inside of a container that contains just the runtime and dotnet specific images but no IIS. I used to think that Asp.net core web app requires a server and that could be either IIS or Kestrel but in my case I didn't have any of those. I ran my app in both Linux and Windows container. While in Linux container, I thought maybe behind the scenes Kestrel would be running but that shouldn't be the case in Windows container or maybe I am wrong all together.

    So I just want to know how are the thing running in containers without a server? Also if possible can you please point me to articles explaining difference in performance as well

    Sunday, June 14, 2020 2:13 PM

All replies

  • User-474980206 posted

    Asp.net core apps are command line programs. Krestrel is the built in library that implements a web server. You can run an asp.net core app on windows or Linux standalone  and access with a browser. Just build and run the exe. 

    when you run asp.net in a container, you are just running the exe, and exposing the port it’s listening on.

    running asp.net core standalone may be faster than hosting in iis or ngnix but you are missing features, that iis or ngnix supply. For example iis has static file caching, and can host multiple application on the same port.

    Sunday, June 14, 2020 4:30 PM
  • User-1045336983 posted

    I thought if I deploy my application as self-contained then it would be creating exe file else dll. 

    Wednesday, June 17, 2020 7:24 AM
  • User-474980206 posted

    Self contained means all the .net runtimes dlls are included rather than sharing the ones installed on the deployment computer.

    in reality, there is only a dll produced. The exe is stripped down version of dotnet.exe which hosts the dll. .net core, like java requires a hosting program to run the code.

    note: typically you would pull a docker container with .net core already installed. so you did not need self contained deployment.

    Wednesday, June 17, 2020 3:07 PM
  • User-782232518 posted

    I used to think that Asp.net core web app requires a server and that could be either IIS or Kestrel but in my case I didn't have any of those.

    You misunderstood the basic concepts here. An ASP.NET Core always runs on Kestrel (except IIS in-process hosting where IISHttpServer is used).

    Therefore, on a Linux Docker container, HTTP requests land on Kestrel and then are dispatched to the middleware behind.

    IIS is really optional when you host your app on Windows, but you do get some nice web server features from it (application pool for example).

    Thursday, June 18, 2020 1:13 AM
  • User-1045336983 posted

    Ok.. On linux containers, asp.net core requests are served through kestrel but what if I am using windows container?

    Sunday, July 5, 2020 3:47 PM
  • User-474980206 posted

    Just like you can pull a Linux container with ngnix or Apache, you can pull a windows container with iis installed. When running asp.net core in a windows container, you have the choice of hosting with iis or without.

    Sunday, July 5, 2020 6:16 PM