在 Windows 服务器核心 Docker 上安装 .NET Framework 3.5
Install .NET Framework 3.5 on Windows Server Core Docker
我正在努力在 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"]
当我尝试构建它时,它在 RUN dism
行给我错误
Error: 0x800f081f
The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.
现在,即使我在 docker (docker exec) 中 运行 dism /online /enable-feature /featurename:NetFX3 /all
它仍然会给我同样的错误。
有人帮忙吗?
我采取了以下步骤来解决这个问题:
- 获得 Windows Server 2016 Core ISO 文件。已将文件装载到本地计算机上。
- 将 {mount}:/sources/sxs 文件夹解压缩到一个 zip 文件 (sxs.zip)。确保 .NET Framework 3.5 cab 文件 (microsoft-windows-netfx3-ondemand-package.cab) 存在于 sxs 文件夹中。就我而言,这是 sxs 文件夹中存在的唯一文件。
- 将 sxs.zip 文件复制到我的容器中。我是用镜像的dockerfile复制过来的。
- 将文件解压到容器中的C:\sources\sxs文件夹。
使用 Install-WindowsFeature powershell 命令安装功能。
Install-WindowsFeature -Name NET-Framework-Features -Source C:\sources\sxs -Verbose
希望这对您有所帮助。我还发现以下博客有助于理解点播功能。
https://blogs.technet.microsoft.com/askcore/2012/05/14/windows-8-and-net-framework-3-5/
对于那些仍然需要 .Net3.5 和 .Net4.X(我的情况是 4.7.2)版本的人来说。
请注意,MSFT 了解此需求,并拥有此方案的基础映像。
在你的 dockerfile 中使用 FROM mcr.microsoft.com/dotnet/framework/sdk:3.5-20191008-windowsservercore-ltsc2019
。
为我省去了所有的安装麻烦。
我正在努力在 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"]
当我尝试构建它时,它在 RUN dism
Error: 0x800f081f
The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.
现在,即使我在 docker (docker exec) 中 运行 dism /online /enable-feature /featurename:NetFX3 /all
它仍然会给我同样的错误。
有人帮忙吗?
我采取了以下步骤来解决这个问题:
- 获得 Windows Server 2016 Core ISO 文件。已将文件装载到本地计算机上。
- 将 {mount}:/sources/sxs 文件夹解压缩到一个 zip 文件 (sxs.zip)。确保 .NET Framework 3.5 cab 文件 (microsoft-windows-netfx3-ondemand-package.cab) 存在于 sxs 文件夹中。就我而言,这是 sxs 文件夹中存在的唯一文件。
- 将 sxs.zip 文件复制到我的容器中。我是用镜像的dockerfile复制过来的。
- 将文件解压到容器中的C:\sources\sxs文件夹。
使用 Install-WindowsFeature powershell 命令安装功能。
Install-WindowsFeature -Name NET-Framework-Features -Source C:\sources\sxs -Verbose
希望这对您有所帮助。我还发现以下博客有助于理解点播功能。 https://blogs.technet.microsoft.com/askcore/2012/05/14/windows-8-and-net-framework-3-5/
对于那些仍然需要 .Net3.5 和 .Net4.X(我的情况是 4.7.2)版本的人来说。
请注意,MSFT 了解此需求,并拥有此方案的基础映像。
在你的 dockerfile 中使用 FROM mcr.microsoft.com/dotnet/framework/sdk:3.5-20191008-windowsservercore-ltsc2019
。
为我省去了所有的安装麻烦。