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

I’m trying out all kind of new features of asp.net 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.

  • Build docker in ASP.NET Core: “no such file or directory” error
  • Deploying ASP.NET 5 app to EC2 in a Docker container
  • ASP.NET 5 on Azure Docker on Ubuntu Server
  • How to run sql script before the application launches in docker
  • “The directory name /app/Views/ is invalid” on ASP.NET Core deployment using docker
  • Connect to SQL Server on Linux (docker) using SQL Management Studio
  • 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: https://github.com/mastoj/OneManBlog/blob/master/src/OneManBlog/Dockerfile

  • How to make a build arg mandatory during Docker build?
  • Docker vs old approach (supervisor, git, your project)
  • Docker private registries and the default installer
  • Docker not working in Windows10
  • Docker (rails) - Changes in server side code, require restart app
  • How to create a DB for MongoDB container on start up?
  • One Solution collect form web for “Docker container based on microsoft/aspnet can't load Kestrel”

    The microsoft/aspnet base image (https://github.com/aspnet/aspnet-docker/blob/master/1.0.0-beta4/Dockerfile) 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.