基于microsoft / aspnet的Docker容器无法加载Kestrel

时间:2015-05-15 20:24:19

标签: asp.net docker asp.net-core

我尝试了asp.net 5的各种新功能并记录它,现在我遇到了第一个障碍。我无法让我的代码在docker容器中运行,我甚至都没有尝试让容器听取更改,我只是想让它运行。

我已将我的图片基于microsoft/aspnet,并添加了代码来安装nodenpmbowergrunt,以便我可以构建应用在容器中。我知道我可能可以在将它添加到容器之前在客户端中构建它,但我想尝试一下。图像构建正常,但是当我启动容器时,它无法找到Kestrel

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

我不应该Kestrel已经存在,因为我基于microsoft/aspnet吗?

我的Dockerfile的代码:https://github.com/mastoj/OneManBlog/blob/master/src/OneManBlog/Dockerfile

1 个答案:

答案 0 :(得分:3)

microsoft / aspnet基本映像(https://github.com/aspnet/aspnet-docker/blob/master/1.0.0-beta4/Dockerfile)仅为您提供运行Kestrel所需的最小发行版,包括dnvm和最新的dnx,但不是Kestrel本身。将Kestrel NuGet包添加到project.json中的依赖项并再次构建docker镜像:

"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"
}

编辑:对您的回购进行了测试并确保其有效:)