VS BuildTools 不会安装在 windows 服务器 2016 上的 docker 容器中

VS BuildTools won't install in docker container on windows server 2016

我按照此 guide 进行了一次修改:我使用了 ltsc2016 而不是 ltsc2019,因为在 windows 服务器 2016 上你不能使用 ltsc2019。

在 运行 阶段之前一切正常:安装程序产生了一些输出,然后突然(最后一行输出被截断了一半)停止了任何操作。

示例输出:

PS> docker build -t buildtools2019:latest -m 2GB .
Sending build context to Docker daemon  1.291MB
Step 1/6 : FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2016
 ---> 60b66cbb41a3
Step 2/6 : SHELL cmd /S /C
 ---> Using cache
 ---> fd7a0b7ae860
Step 3/6 : ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
Downloading [==================================================>]   1.34MB/1.34MB

 ---> Using cache
 ---> 91ea2d1b1299
Step 4/6 : RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache     --installPath C:\BuildTools     --all     --remove Microsoft.VisualStudio.Component.Windows10SDK.10240     --remove Microsoft.VisualStudio.Component.Windows10SDK.10586     --remove Microsoft.VisualStudio.Component.Windows10SDK.14393     --remove Microsoft.VisualStudio.Component.Windows81SDK  || IF "%ERRORLEVEL%"=="3010" EXIT 0
 ---> Running in 2f63ab89f5db
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile28\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile52\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile29\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile31\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile55\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile46\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile42\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile36\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile82\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile40\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile45\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile41\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile49\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\HelpFile33\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\vs_setup_bootstrapper.exe...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\Microsoft.Diagnostics.Tracing.EventSource.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\Microsoft.VisualStudio.RemoteControl.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\Microsoft.VisualStudio.Setup.Common.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\Microsoft.VisualStudio.Setup.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\Microsoft.VisualStudio.Setup.Download.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\Microsoft.VisualStudio.Telemetry.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\Microsoft.VisualStudio.Utilities.Internal.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\Newtonsoft.Json.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\zh-Hans\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\zh-Hant\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\tr\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\pt-BR\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\cs\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\fbc497b0c200d3c7418623ae\vs_bootstrapper_d15\es\vs_

这是因为您是 运行 驱动器 space 上的 C 驱动器,容器内有 20GB。不幸的是 build 不支持指定 storage-opt 所以我不相信目前有解决方案。参考这个仍然开放的工单(https://github.com/moby/moby/issues/34947)