无法在Docker上运行asp.net mvc 6
我遵循Visual Studio代码的指导来创build一个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"]
然后我试图build立它
docker build -t thangchung/webdemo .
和
docker run -i -p 8080:5001 -t thangchung/webdemo
当我运行上面的代码的时候,它总是抛出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
任何人都可以让我知道为什么我不能在Docker上运行它?
任何build议是值得欢迎的。 谢谢。
你有没有使用正确的Docker图像从aspnet-docker github项目 ?
在msdn上运行Docker上的ASP.NET 5的文章 – 链接
编辑:
根据文章 – 你错过了
RUN ["kpm", "restore"]
在Dockerfile
。
适用于2015年5月的ASP.NET 5的文章: https : //alexanderzeitler.com/articles/Running-ASP.NET-5-beta4-in-Docker-with-DNX-runtime/
随着从k到dnx的更新,你现在必须为包含你的project.json的目录提供一个path参数。 所以曾经是
k kestrel
变
dnx . kestrel