Pat*_*ott 20 iis-7 asp-classic docker docker-for-windows docker-desktop
微软一直在投资使用Docker Desktop for Windows在Windows上运行docker .是否可以通过Docker在IIS上运行旧版ASP Classic应用程序?怎么样?
Pat*_*ott 40
我终于把这一切都搞定了.它比运行简单的Dockerfile复杂得多,因为它是最初在2002年开发的站点.有必须下载和安装的模块,需要解锁的web.config部分以及ODBC数据连接不得不做.我的最终docker文件看起来像这样 - 希望它能帮助下一个人!
# escape=`
FROM microsoft/iis
SHELL ["powershell", "-command"]
RUN Install-WindowsFeature Web-ASP; `
Install-WindowsFeature Web-CGI; `
Install-WindowsFeature Web-ISAPI-Ext; `
Install-WindowsFeature Web-ISAPI-Filter; `
Install-WindowsFeature Web-Includes; `
Install-WindowsFeature Web-HTTP-Errors; `
Install-WindowsFeature Web-Common-HTTP; `
Install-WindowsFeature Web-Performance; `
Install-WindowsFeature WAS; `
Import-module IISAdministration;
RUN md c:/msi;
RUN Invoke-WebRequest 'http://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi' -OutFile c:/msi/urlrewrite2.msi; `
Start-Process 'c:/msi/urlrewrite2.msi' '/qn' -PassThru | Wait-Process;
RUN Invoke-WebRequest 'https://download.microsoft.com/download/1/E/7/1E7B1181-3974-4B29-9A47-CC857B271AA2/English/X64/msodbcsql.msi' -OutFile c:/msi/msodbcsql.msi;
RUN ["cmd", "/S", "/C", "c:\\windows\\syswow64\\msiexec", "/i", "c:\\msi\\msodbcsql.msi", "IACCEPTMSODBCSQLLICENSETERMS=YES", "ADDLOCAL=ALL", "/qn"];
EXPOSE 8000
RUN Remove-Website -Name 'Default Web Site'; `
md c:\mywebsite; `
New-IISSite -Name "mywebsite" `
-PhysicalPath 'c:\mywebsite' `
-BindingInformation "*:8000:";
RUN & c:\windows\system32\inetsrv\appcmd.exe `
unlock config `
/section:system.webServer/asp
RUN & c:\windows\system32\inetsrv\appcmd.exe `
unlock config `
/section:system.webServer/handlers
RUN & c:\windows\system32\inetsrv\appcmd.exe `
unlock config `
/section:system.webServer/modules
RUN Add-OdbcDsn -Name "mywebsite" `
-DriverName "\"ODBC Driver 13 For SQL Server\"" `
-DsnType "System" `
-SetPropertyValue @("\"Server=XXXX.us-east-2.rds.amazonaws.com\"", "\"Trusted_Connection=No\"");
ADD . c:\mywebsite
Run Code Online (Sandbox Code Playgroud)
我没有尝试过,但运行经典 ASP 应该不是问题。该microsoft/iis映像基于microsoft/windowsservercore完整的服务器核心安装映像,并且还包括 32 位支持。
默认情况下,ASP 功能不会存在,因此您的 Dockerfile 必须像这样启动:
# escape=`
FROM microsoft/iis
SHELL ["powershell", "-command"]
RUN Install-WindowsFeature Web-ASP
Run Code Online (Sandbox Code Playgroud)
(escape和SHELL行只是让构建 Windows 友好的 Dockerfile 变得更容易,请参阅Windows、Dockerfiles 和 Backtick Backslash Backlash)。
然后,您将COPY在 ASP 应用程序文件夹中,使用 PowerShell 命令运行 IIS 设置的其余部分。这个问题有一些很好的指导,这个 ASP.NET 应用程序的 Dockerfile展示了如何使用 PowerShell 来配置网站。
| 归档时间: |
|
| 查看次数: |
6299 次 |
| 最近记录: |