I am try to create a working docker image for a legacy .net framework application (.net framework 4.6) What I did so far:
Where I am struggling is executing the application. IIS won't recognize the application and throws a 500 internal server error.
Here my docker file.
FROM mcr.microsoft.com/windows/servercore/iis
RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*
WORKDIR /inetpub/wwwroot
COPY . .
I took the instructions from https://hub.docker.com/_/microsoft-windows-servercore-iis.
The error I am getting when running the container is the following, when navigating to the page in my browser. localhost:8000/application/admin
To fix the error, I tried the following:
connectionstrings
CustomErrors
to Off
wwwroot/inetpub
folder to everyone and fullUnfortunately with I get the same results. It doesn't seems to recognize the application. I struggle even to get the first login page it I don't see anything in the even logs.
I would appreciate any help very much. Thanks in advance!
Edit 1:
thanks for all the help. It pointed me in the right direction. It was necessary to install url re-write and some IIS modules in order for the application to work. Also I experienced issues with the SQL server linux image in Docker desktop mixed mode. But there is an older version of SQL server for windows which worked. https://hub.docker.com/r/microsoft/mssql-server-windows-developer
Here my docker file I hope it can help somebody else
FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2022
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