1

如何使用在.NET Framework上运行的ASP.NET Core WebApi创建 Windows 容器?

我应该使用什么基础镜像,我应该如何构建/发布项目?dockerfile 的简单示例会很棒。

WebApi 中还引用了 .NET Framework 4.6.2 项目。

4

2 回答 2

0

我设法让它与容器中的 IIS 一起工作。我必须弄清楚“如何在 IIS 中托管 ASP.NET Core 应用程序”。教程在这里。这可以通过安装ASP.NET Core 模块来完成。所以最后我的 Dockerfile 看起来像:

FROM microsoft/iis

#install ASPO.NET Core Module (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/aspnet-core-module?view=aspnetcore-2.1)
WORKDIR /temp
ADD https://download.microsoft.com/download/6/E/B/6EBD972D-2E2F-41EB-9668-F73F5FDDC09C/dotnet-hosting-2.1.3-win.exe dotnethosting.exe
RUN dotnethosting.exe /quiet /install

#you should restart IIS, but its not necessary, when youre building image
#RUN powershell -command net stop was /y
#RUN powershell -command net start w3svc

RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*

WORKDIR /inetpub/wwwroot

#replace with your published web application
COPY bin/release/net462/publish .
于 2018-08-30T08:54:10.270 回答
0

由于您依赖于完整的 .NET 框架,因此您的基础映像需要是https://hub.docker.com/r/microsoft/dotnet-framework/并且您必须自己将 .NET 核心安装到映像中。Microsoft 没有提供在单个图像中同时具有两个版本的 .NET 框架的解决方案。

于 2018-08-28T15:16:06.967 回答