我想创建一个具有特定构建环境的docker镜像,这涉及安装VS2017。我尝试了几种方法但总的来说我无法让VS2017安装在docker容器中。将dockerfile减少到最小,我尝试运行它:
FROM microsoft/windowsservercore
SHELL [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';" ]
RUN iwr -uri https://aka.ms/vs/15/release/vs_community.exe -outfile C:\vs_community.exe ; \
C:\vs_community.exe --allWorkloads --includeRecommended --includeOptional -q --passive --norestart --wait --all
以下是安装日志:https://gist.github.com/bazzilic/81fa3d8c4663540872be1d66cd1b0301
看起来一切都很顺利,然而,VS2017最终没有安装 :
PS C:\> ls
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/16/2016 9:18 PM PerfLogs
d-r--- 9/3/2017 7:45 PM Program Files
d----- 9/3/2017 7:41 PM Program Files (x86)
d-r--- 8/8/2017 5:27 AM Users
d----- 8/8/2017 5:25 AM Windows
-a---- 11/23/2016 6:45 AM 1894 License.txt
-a---- 9/3/2017 7:41 PM 1069968 vs_community.exe
PS C:\> cd '.\Program Files\'
PS C:\Program Files> ls
Directory: C:\Program Files
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/16/2016 9:18 PM Common Files
d----- 7/16/2016 9:18 PM internet explorer
d----- 9/3/2017 7:45 PM Windows Defender
d----- 7/16/2016 9:18 PM WindowsPowerShell
PS C:\Program Files> cd '..\Program Files (x86)\'
PS C:\Program Files (x86)> ls
Directory: C:\Program Files (x86)
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/16/2016 9:18 PM Common Files
d----- 7/16/2016 9:18 PM internet explorer
d----- 7/16/2016 9:18 PM Microsoft.NET
d----- 8/8/2017 5:16 AM Windows Defender
d----- 7/16/2016 9:18 PM WindowsPowerShell
PS C:\Program Files (x86)>
有什么建议吗?
答案 0 :(得分:2)
我粘贴了一个Dockerfile,在该文件下我成功地使用VS2017社区,git,Chocolatey和NuGet安装了一个容器。我没有安装所有的VS工作负载,仅安装了4个,但这会导致容器变大。
您可以使用“ docker container run -it -v C:/ Temp:C:/ DATA vs2017 / community”运行它,以交互方式运行它,并将C:\ Temp作为C:\ data挂载在主机上(并向您显示开发人员cmd提示)
希望这会有所帮助。 标记
# USAGE NOTES:
#
# Step 1)
# Docker => Settings => Daemon => Switch from Basic to Advanced
# Add :
# "storage-opts": [
# "size=120GB"
# ]
#
# Step 2)
# docker image build -t vs2017/community -m 2GB .
#
# References:
# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community
#
# NOTE: this build takes ~01:56:17.6201326 hrs on a surface book 2 15" with 16 GB RAM
# and results in an image size of 23.6GB
#
# Use the latest Windows Server Core image
FROM microsoft/windowsservercore:latest
# Download the tools
SHELL ["cmd", "/S", "/C"]
ADD "https://aka.ms/vs/15/release/vs_community.exe" "C:\TEMP\vs_community.exe"
ADD "https://dist.nuget.org/win-x86-commandline/v4.7.0/nuget.exe" "C:\TEMP\nuget.exe"
# Install VS 2017 community
RUN C:\TEMP\vs_community.exe --includeRecommended --includeOptional --quiet --nocache --norestart --wait \
--add Microsoft.VisualStudio.Workload.Azure \
--add Microsoft.VisualStudio.Workload.ManagedDesktop \
--add Microsoft.VisualStudio.Workload.NetCoreTools \
--add Microsoft.VisualStudio.Workload.NetWeb \
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
# Install SSDT NuGet
RUN "C:\TEMP\nuget.exe" install Microsoft.Data.Tools.Msbuild -Version 10.0.61804.210
# Install Chocolatey
ENV chocolateyUseWindowsCompression = false
SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
[System.Environment]::SetEnvironmentVariable('PATH', "\"${env:PATH};%ALLUSERSPROFILE%\chocolatey\bin\"", 'Machine'); \
choco feature enable -n allowGlobalConfirmation;
# Install git tools with chocolatey
RUN choco install git -y \
git-lfs -y \
git-credential-manager-for-windows -y
# Launch VS2017 developer command prompt when started
SHELL ["cmd", "/S", "/C"]
ENTRYPOINT [ "CMD", "/k", "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/Tools/VsDevCmd.bat" ]