在IIS上Dockerize ASP Classic

问题描述 投票:17回答:2

微软一直在投资使用Docker Desktop for Windows在Windows上运行docker。是否可以通过Docker在IIS上运行旧版ASP Classic应用程序?怎么样?

https://hub.docker.com/r/microsoft/iis/

docker asp-classic iis-7 docker-for-windows docker-desktop
2个回答
39
投票

我终于把这一切都搞定了。它比运行简单的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

3
投票

我没有尝试,但运行经典ASP不应该是一个问题。 microsoft/iis映像基于microsoft/windowsservercore映像,这是一个完整的服务器核心安装,还包括32位支持。

默认情况下ASP功能不存在,所以你的Dockerfile必须像这样开始:

# escape=`
FROM microsoft/iis
SHELL ["powershell", "-command"]
RUN Install-WindowsFeature Web-ASP

escapeSHELL行只是使构建Windows友好的Dockerfiles更容易,请参阅Windows, Dockerfiles and the Backtick Backslash Backlash)。

然后,您将在ASP app文件夹中使用COPY,并使用PowerShell命令运行其余的IIS设置。 This question有一些很好的指针,this Dockerfile for an ASP.NET app展示了如何使用PowerShell配置网站。

© www.soinside.com 2019 - 2024. All rights reserved.