作者:难耐五更寒 | 来源:互联网 | 2023-01-31 14:17
我正在努力在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
错误:0x800f081f
找不到源文件.
使用"源"选项指定还原功能所需文件的位置.有关指定源位置的详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=243077.
现在,即使我dism /online /enable-feature /featurename:NetFX3 /all
在docker(docker exec)内部运行,它仍然会给我同样的错误.
有帮助的人吗?
1> ansariwn..:
我采取了以下步骤来解决此问题:
掌握了Windows Server 2016 Core ISO文件.在本地计算机上安装文件.
将{mount}:/ sources/sxs文件夹解压缩为zip文件(sxs.zip).确保sxs文件夹中存在.NET Framework 3.5 cab文件(microsoft-windows-netfx3-ondemand-package.cab).就我而言,这是sxs文件夹中唯一存在的文件.
![sxs文件夹](https://img.php1.cn/3cd4a/1eebe/cd5/d05d9dfd09a56332.webp)
将sxs.zip文件复制到我的容器中.我使用图像的dockerfile复制了它.
将文件解压缩到容器中的C:\ sources\sxs文件夹.
使用Install-WindowsFeature powershell命令安装该功能.
Install-WindowsFeature -Name NET-Framework-Features -Source C:\sources\sxs -Verbose
![安装命令](https://img.php1.cn/3cd4a/1eebe/cd5/0ef126b5295c089b.webp)
希望这可以帮助.我还发现以下博客有助于理解按需功能.
https://blogs.technet.microsoft.com/askcore/2012/05/14/windows-8-and-net-framework-3-5/