Docker .net 框架应用程序

Docker .net framework application

我正在尝试为遗留 .net 框架应用程序(.net 框架 4.6)创建工作 docker 图像 到目前为止我做了什么:

我遇到困难的地方是执行应用程序。 IIS 将无法识别该应用程序并引发 500 内部服务器错误。

这是我的 docker 文件。

FROM mcr.microsoft.com/windows/servercore/iis

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

WORKDIR /inetpub/wwwroot

COPY . .

我接受了 https://hub.docker.com/_/microsoft-windows-servercore-iis 的说明。

在我的浏览器中导航到页面时,运行安装容器时出现的错误如下。 localhost:8000/application/admin

为了修复错误,我尝试了以下方法:

不幸的是,我得到了相同的结果。它似乎无法识别该应用程序。我什至很难获得第一个登录页面,因为我在偶数日志中没有看到任何内容。

非常感谢任何帮助。提前致谢!

编辑 1:

感谢所有帮助。它为我指明了正确的方向。必须安装 url re-write 和一些 IIS 模块才能使应用程序正常工作。此外,我在 Docker 桌面混合模式下遇到 SQL 服务器 linux 图像的问题。但是 windows 有一个旧版本的 SQL 服务器可以工作。 https://hub.docker.com/r/microsoft/mssql-server-windows-developer

这是我的 docker 文件,希望它能帮助到其他人

FROM mcr.microsoft.com/windows/servercore/iis

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

RUN powershell -Command Invoke-WebRequest http://download.microsoft.com/download/D/D/E/DDE57C26-C62C-4C59-A1BB-31D58B36ADA2/rewrite_amd64_en-US.msi -OutFile c:/inetpub/rewrite_amd64_en-US.msi
RUN powershell -Command Start-Process c:/inetpub/rewrite_amd64_en-US.msi -ArgumentList "/qn" -Wait

RUN cmd /c C:\Windows\system32\inetsrv\appcmd.exe  unlock config -section:system.webServer/handlers
RUN cmd /c C:\Windows\system32\inetsrv\appcmd.exe set apppool /apppool.name:DefaultAppPool /enable32BitAppOnWin64:true

RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-CommonHttpFeatures
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpErrors
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpRedirect
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationDevelopment
RUN powershell -Command Enable-WindowsOptionalFeature -online -FeatureName NetFx4Extended-ASPNET45
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-NetFxExtensibility45
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-HealthAndDiagnostics
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpLogging
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-LoggingLibraries
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestMonitor
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-Security
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestFiltering
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-Performance
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerManagementTools
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-Metabase
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-StaticContent
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-DefaultDocument
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebSockets
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationInit
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIExtensions
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIFilter
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpCompressionStatic
RUN powershell -Command Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45

WORKDIR /inetpub/wwwroot

COPY . .

RUN cmd /c icacls C:/inetpub/wwwroot /grant:r Everyone:F /t