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

标签 c# .net docker dockerfile

我正在努力在 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 它仍然会给我同样的错误。

有人帮忙吗?

最佳答案

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

  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 folder

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

    Install-WindowsFeature -Name NET-Framework-Features -Source C:\sources\sxs -Verbose
    

    install command

希望这会有所帮助。我还发现以下博客有助于理解按需功能。 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/

相关文章:

c# - EntityType 'Worker' 没有定义键。定义此 EntityType 的键

c# - 从 Gridview 的可见 false BoundField 中检索数据

docker - Traefik:级别=错误消息=“field not found, node: mywebsite”提供商名称=docker

c# - 如何使用 ASP.NET 将 LinkBut​​ton 放入工具提示中?

c# - SortedDictionary.Count 的成本

c# - 通过 .net 将 excel 列格式化为 "yyyy-MM-dd"

.net - 一个 dbml 中的数据库很少?

c# - 如何动态创建 .NET C# ValueType 元组?

django - Docker和Django。 django.db.utils.OperationalError:无法连接到服务器

docker - 在 GitLab CI 中使用带有已安装 `/var/run/docker.sock` 的 BuildKit