gpt4 book ai didi

c# - 无法在 Docker 上运行 asp.net mvc 6

转载 作者:行者123 更新时间:2023-11-30 20:43:50 25 4
gpt4 key购买 nike

我遵循了 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 镜像? ?

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

编辑:

根据文章 - 你失踪了

RUN ["kpm", "restore"]

Dockerfile 中。

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

关于c# - 无法在 Docker 上运行 asp.net mvc 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30054505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com