2015-05-05 78 views
2

我按照Visual Studio Code的指導創建ASP.NET MVC應用程序。我可以在我的本地(Windows 8)上運行它。但是當我試圖將其發佈到Docker時,問題就發生了。無法在Docker上運行asp.net mvc 6

我喜歡

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

dockerfile然後我試圖建立它

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上運行它嗎?

任何建議是值得歡迎的。謝謝。

回答

3

你有沒有使用正確的碼頭圖像從aspnet-docker github project

文章關於在MSDN上泊塢運行ASP.NET 5 - link

編輯:

據文章 - 你在Dockerfile失蹤

RUN ["kpm", "restore"] 

條恰當的ASP.NET 5在2015年5月: https://alexanderzeitler.com/articles/Running-ASP.NET-5-beta4-in-Docker-with-DNX-runtime/

+0

是的,我有。我使用1.0.0-beta4標籤,並檢查了project.json中的所有版本都是一樣的。 – thangchung

+0

檢查我的編輯,我認爲你應該使用'kpm'(來自asp.net),而不是'dnu' – michalczukm

+0

我認爲MSDN的教程是舊的。現在你必須運行dnu和dnx命令,而不是kpm和k了:( – thangchung

1

從k處的更新DNX你現在必須爲包含您project.json的目錄路徑參數。因此,曾經被認爲是

k kestrel 

成爲

dnx . kestrel