docker - 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 ;
解决方案
推荐阅读
- ios - Realm iOS:使用捆绑的数据库启动 Realm 的成本是多少?
- c# - C# 找不到关于自动更新文本框 WITH 计算的初学者解释
- java - 重新排列一个数组,使得 arr[i] = i
- cordova - 在 Cordova 插件中包含 Storyboard 或 xib 文件
- php - CURL 帖子无法将 csv 数据上传到 blaynmail
- android - 在 LinearLayout 中查找 LinearLayout 的子项
- bash - 如何在不使用重定向运算符的情况下写入文件?
- for-loop - 带有 StringBuilder 的 Java 循环逻辑 (Hangman)
- java - 功能文件中的 testdata 列数是否有任何限制 - selenium java
- c# - 从 JSON Schema 为 Sabre REST API 生成 C# 模型类