在Windows Server Core Docker上安装.NET Framework 3.5

我正努力在Docker容器上安装.NET Framework 3.5。 我已经安装了4.5,但需要3.5来运行一个服务。 这是我的Dockerfile:

FROM microsoft/windowsservercore SHELL ["powershell"] RUN Install-WindowsFeature NET-Framework-45-ASPNET ; \ Install-WindowsFeature Web-Asp-Net45 RUN dism /online /enable-feature /featurename:NetFX3 /all COPY Startup Startup COPY Service Service RUN "C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" WCS.WindowsService.exe RUN mkdir Temp\Logs ENTRYPOINT C:\Startup\setupBatch.bat COPY ContainerApi ContainerApi RUN Remove-WebSite -Name 'Default Web Site' RUN New-Website -Name 'ContainerApi' -Port 80 \ -PhysicalPath 'C:\ContainerApi' -ApplicationPool '.NET v4.5' EXPOSE 80 CMD ["ping", "-t", "localhost"] 

当我尝试build立这个,它给我错误在线RUN dism

错误:0x800f081f

源文件找不到。
使用“源”选项指定恢复function所需文件的位置。 有关指定源位置的更多信息,请参阅http://go.microsoft.com/fwlink/?LinkId=243077 。

现在,即使我运行dism /online /enable-feature /featurename:NetFX3 /all exec)中的dism /online /enable-feature /featurename:NetFX3 /all内容,仍然会给我同样的错误。

任何人有任何帮助?

我采取了以下步骤来解决这个问题:

  1. 掌握了Windows Server 2016 Core ISO文件。 将文件安装在本地计算机上。
  2. 将{mount}:/ sources / sxs文件夹解压缩为一个zip文件(sxs.zip)。 确保.NET Framework 3.5 cab文件(microsoft-windows-netfx3-ondemand-package.cab)存在于sxs文件夹中。 就我而言,这是sxs文件夹中唯一存在的文件。

sxs文件夹

  1. 将sxs.zip文件复制到我的容器中。 我使用图像的dockerfile复制它。
  2. 将文件解压缩到容器中的C:\ sources \ sxs文件夹中。
  3. 使用Install-WindowsFeature powershell命令来安装该function。

    Install-WindowsFeature – 名称NET-Framework-Features – 源C:\ sources \ sxs -Verbose 安装命令

希望这可以帮助。 我还发现以下博客有助于理解按需function。 https://blogs.technet.microsoft.com/askcore/2012/05/14/windows-8-and-net-framework-3-5/