我正在努力在 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/
关于c# - 在 Windows Server Core Docker 上安装 .NET Framework 3.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44717156/