无法 运行 asp.net Docker 上的 mvc 6

Could not run asp.net mvc 6 on Docker

我按照 Visual Studio Code 的指导创建了一个 ASP.NET MVC 应用程序。我可以 运行 在本地 (windows 8)。但是当我试图将它发布到 Docker 时,问题发生了。

我的 dockerfile 喜欢

FROM microsoft/aspnet:1.0.0-beta4

#install npm in docker image
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get install -y nodejs

#install bower and grunt
RUN npm install -g bower
RUN npm install -g grunt-bower-cli
RUN npm install -g grunt
RUN npm install -g grunt-cli
RUN npm install -g grunt-bower-task

COPY project.json /app/

WORKDIR /app

RUN ["dnu", "restore"]

COPY . /app

CMD ["cd", "/app/"]
CMD ["npm", "install"]
CMD ["bower", "install"]

EXPOSE 5001

ENTRYPOINT ["dnx", "kestrel"]

然后我尝试构建它

docker build -t thangchung/webdemo .

docker run -i -p 8080:5001 -t thangchung/webdemo

问题是当我运行上面的代码时,它总是抛出异常

System.InvalidOperationException: Unable to resolve project 'kestrel' from /app/kestrel
  at Microsoft.Framework.Runtime.ApplicationHostContext..ctor (IServiceProvider serviceProvider, System.String projectDirectory, System.String packagesDirectory, System.String configuration, System.Runtime.Versioning.FrameworkName targetFramework, ICache cache, ICacheContextAccessor cacheContextAccessor, INamedCacheDependencyProvider namedCacheDependencyProvider, IAssemblyLoadContextFactory loadContextFactory, Boolean skipLockFileValidation) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.Runtime.DefaultHost.Initialize (Microsoft.Framework.Runtime.DefaultHostOptions options, IServiceProvider hostServices) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.Runtime.DefaultHost..ctor (Microsoft.Framework.Runtime.DefaultHostOptions options, IServiceProvider hostServices) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.ApplicationHost.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

谁能告诉我为什么我不能在 Docker 上 运行 吗?

欢迎提出任何建议。谢谢。

您是否使用了来自 aspnet-docker github project 的 Docker 图片?

有关 运行 ASP.NET 5 的文章 Docker at msdn - link

编辑:

根据文章 - 你失踪了

RUN ["kpm", "restore"]

Dockerfile.

2015 年 5 月 ASP.NET5 的专有文章: https://alexanderzeitler.com/articles/Running-ASP.NET-5-beta4-in-Docker-with-DNX-runtime/

随着从 k 到 dnx 的更新,您现在必须为包含您的 project.json 的目录提供路径参数。那么曾经是

k kestrel

变成

dnx . kestrel