Docker container based on microsoft/aspnet can't load Kestrel

I’m trying out all kind of new features of 5 and documenting it and now I hit the first obstacle. I can’t get my code to run in a docker container, I’m not even trying to get the container to listen to changes, I just want it to run.

I’ve based my image on microsoft/aspnet and added code to install node, npm, bower and grunt so I can build the application in the container. I know I probably can build it in the client before I add it to the container, but I want to give this a try. The image builds fine, but when I start the container it can’t find Kestrel.

  • Does Azure Service Fabric do the same thing as Docker?
  • Docker not hosting anything on the port it says it is, what's going on?
  • Docker on Windows Connecting to sql server from dotnetcore app
  • How to copy image into VS2015 in order to amend code
  • Can I run existing ASP.NET MVC application in Docker without converting to ASP.NET Core in Linux
  • Debug ASP.NET Core on Docker in Visual Studio Code
  • System.IO.FileNotFoundException: Could not load file or assembly 'Kestrel' or one of its dependencies. The system cannot find the file specified.
    File name: 'Kestrel'
      at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x00000] in <filename unknown>:0
      at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
      at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in <filename unknown>:0
      at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName)
      at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in <filename unknown>:0
      at Microsoft.AspNet.Hosting.Server.ServerLoader.LoadServerFactory (System.String serverFactoryIdentifier) [0x00000] in <filename unknown>:0
      at Microsoft.AspNet.Hosting.HostingEngine.EnsureServerFactory (Microsoft.AspNet.Hosting.HostingContext context) [0x00000] in <filename unknown>:0
      at Microsoft.AspNet.Hosting.HostingEngine.Start (Microsoft.AspNet.Hosting.HostingContext context) [0x00000] in <filename unknown>:0
      at Microsoft.AspNet.Hosting.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
      at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
      at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0

    Shouldn’t Kestrel already exist since I base it on microsoft/aspnet?

    The code to my Dockerfile:

  • Docker Exec Cronjobs Filling Ec2 instance disk space, why?
  • Docker and Eureka with Spring Boot failing to register clients
  • Nginx in Docker container won't run PHP
  • Docker and http url of started web application
  • Docker Host And Other Fundamental Questions
  • making docker containers communicate through port
  • One Solution collect form web for “Docker container based on microsoft/aspnet can't load Kestrel”

    The microsoft/aspnet base image ( only gives you the minimum distro needed to run Kestrel, including dnvm and the latest dnx, but NOT Kestrel itself. Add the Kestrel NuGet package to the dependencies in your project.json and build the docker image again:

    "dependencies": {
        "Microsoft.AspNet.Mvc": "6.0.0-beta4",
        "Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
        "Microsoft.AspNet.StaticFiles": "1.0.0-beta4",
        "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
        "Microsoft.AspNet.Hosting": "1.0.0-beta4",
        "Kestrel": "1.0.0-beta4"

    EDIT: Did a test on your repo and that made it work 🙂

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.