25

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

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

4

3 回答 3

51

我终于让这一切正常了。它比运行一个简单的 Dockerfile 复杂得多,因为它是一个最初于 2002 年开发的站点。有必须下载和安装的模块,需要解锁的 web.config 部分,以及需要解锁的 ODBC 数据连接。必须制作。我最终的 docker 文件看起来像这样 - 希望它可以帮助下一个人!

# escape=`

FROM mcr.microsoft.com/windows/servercore/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
于 2016-11-01T18:36:47.157 回答
5

我没有尝试过,但运行经典 ASP 应该不是问题。该microsoft/iis映像基于该microsoft/windowsservercore映像,该映像是完整的 Server Core 安装,还包括 32 位支持。

默认情况下,ASP 功能不存在,因此您的 Dockerfile 必须像这样开始:

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

escapeSHELL行只是让构建 Windows 友好的 Dockerfile 变得更容易,请参阅Windows、Dockerfiles 和 Backtick Backslash Backlash)。

然后您将COPY在您的 ASP 应用程序文件夹中,并使用 PowerShell 命令运行 IIS 设置的其余部分。这个问题有一些很好的指导,这个 ASP.NET 应用程序的 Dockerfile展示了如何使用 PowerShell 来配置网站。

于 2016-10-18T10:16:24.983 回答
0

更新容器运行所在的 Windows Server(使用 Windows 更新)以匹配容器映像版本非常重要。不这样做会引发各种难以追踪的问题。

于 2020-02-24T14:57:00.543 回答