我正在努力在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
行上给我错误现在,即使我在docker(docker exec)内部运行
dism /online /enable-feature /featurename:NetFX3 /all
,它仍然会给我同样的错误。任何人有帮助吗?
最佳答案
我采取了以下步骤来解决此问题:
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/