简体   繁体   English

无法在Docker上运行ASP.NET MVC 6

[英]Could not run asp.net mvc 6 on Docker

I followed the guidance at Visual Studio Code to create an ASP.NET MVC app. 我按照Visual Studio Code的指导来创建ASP.NET MVC应用程序。 I can run it on my local (windows 8). 我可以在本地(Windows 8)上运行它。 But when I tried to publish it to Docker, and the problem happened. 但是,当我尝试将其发布到Docker时,问题就发生了。

My dockerfile like 我的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"]

Then I tried to build it 然后我试图建立它

docker build -t thangchung/webdemo .

and

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

the problem when I run above code, it always threw exception 我在上面的代码上运行的问题,它总是引发异常

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

Could anyone let me know why I could not run it on Docker? 谁能让我知道为什么我不能在Docker上运行它?

Any suggestion is welcome. 任何建议都欢迎。 Thanks. 谢谢。

Have you use right Docker image from aspnet-docker github project ? 您是否从aspnet-docker github项目使用了正确的Docker映像?

Article about running ASP.NET 5 on Docker at msdn - link 有关在msdn上在Docker上运行ASP.NET 5的文章- 链接

Edit: 编辑:

According to article - you're missing 根据文章-您失踪了

RUN ["kpm", "restore"]

in Dockerfile . Dockerfile

Article proper to ASP.NET 5 at May 2015: https://alexanderzeitler.com/articles/Running-ASP.NET-5-beta4-in-Docker-with-DNX-runtime/ 2015年5月适合ASP.NET 5的文章: https : //alexanderzeitler.com/articles/Running-ASP.NET-5-beta4-in-Docker-with-DNX-runtime/

With the updates from k to dnx you now have to provide a path parameter for the directory containing your project.json. 随着从k到dnx的更新,您现在必须为包含project.json的目录提供路径参数。 So what used to be 那曾经是

k kestrel

becomes

dnx . kestrel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM