首页 > 解决方案 > Windows 容器的 dockerfile 中的问题设置 [Net.ServicePointManager]::SecurityProtocol

问题描述

我正在尝试在 Windows Server 2016 上创建 Windows docker 映像。由于以下错误,我在安装某些软件包时遇到问题:

Exception calling "DownloadFile" with "2" argument(s): "The request was aborted: Could not create SSL/TLS secure channel."

通过一些研究,我发现这通常是由于需要将 [Net.ServicePointManager]::SecurityProtocol 参数设置为 Tls12。当我尝试在本地机器上设置它然后下载包时,它工作正常。但是,当我尝试通过 dockerfile 执行此操作时,它似乎不起作用并且错误保持不变。我在这里做错了吗?

Dockerfile:

FROM mcr.microsoft.com/windows/servercore:ltsc2016

RUN powershell [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

ADD https://chocolatey.org/installchocolatey.cmd .
RUN powershell \      
        [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; \  
        .\installchocolatey.cmd; \
        choco install --yes ghostscript --version=9.24 ;\
        choco install --yes imagemagick --version=7.0.10.14 ;

标签: dockerdocker-for-windows

解决方案


推荐阅读