1+ Vagrant . configure ( "2" ) do |config |
2+ config . winrm . host = "127.0.0.1"
3+ config . winrm . username = "vagrant"
4+ config . winrm . password = "vagrant"
5+ config . vm . box = "symbols/windows_2016_core"
6+ config . vm . box_check_update = false
7+ config . vm . hostname = "docker-windows"
8+ config . vm . network :forwarded_port , id : 'winrm' , guest : 5985 , host : 2201 , auto_correct : false
9+ config . vm . network :forwarded_port , id : 'rdp' , guest : 3389 , host : 2202 , auto_correct : false
10+ config . vm . network :forwarded_port , id : 'docker-http-api' , guest : 4243 , host : 4243 , auto_correct : false
11+ config . vm . network :forwarded_port , id : 'rmq-mqttWithoutTls' , guest : 1883 , host : 1883 , auto_correct : false
12+ config . vm . network :forwarded_port , id : 'rmq-epmd' , guest : 4369 , host : 4369 , auto_correct : false
13+ config . vm . network :forwarded_port , id : 'rmq-amqpWithTls' , guest : 5671 , host : 5671 , auto_correct : false
14+ config . vm . network :forwarded_port , id : 'rmq-amqpWithoutTls' , guest : 5672 , host : 5672 , auto_correct : false
15+ config . vm . network :forwarded_port , id : 'rmq-mqttWithTls' , guest : 8883 , host : 8883 , auto_correct : false
16+ config . vm . network :forwarded_port , id : 'rmq-managementWithTls' , guest : 15671 , host : 15671 , auto_correct : false
17+ config . vm . network :forwarded_port , id : 'rmq-managementWithoutTls' , guest : 15672 , host : 15672 , auto_correct : false
18+ config . vm . network :forwarded_port , id : 'rmq-stompOverWebsockets' , guest : 15674 , host : 15674 , auto_correct : false
19+ config . vm . network :forwarded_port , id : 'rmq-mqttOverWebsockets' , guest : 15675 , host : 15675 , auto_correct : false
20+ config . vm . network :forwarded_port , id : 'rmq-erlangDistribution' , guest : 25672 , host : 25672 , auto_correct : false
21+ config . vm . network :forwarded_port , id : 'rmq-stompWithoutTls' , guest : 61613 , host : 61613 , auto_correct : false
22+ config . vm . network :forwarded_port , id : 'rmq-stompWithTls' , guest : 61614 , host : 61614 , auto_correct : false
23+ config . vm . provider "virtualbox" do |vb |
24+ vb . name = "vm_docker_windows"
25+ vb . cpus = 2
26+ vb . memory = 1024
27+ vb . gui = false
28+ end
29+ config . vm . provision "shell" do |s |
30+ s . powershell_args = '-NoProfile -Noninteractive -NoLogo -ExecutionPolicy Bypass'
31+ s . inline = <<-SHELL . gsub ( /^ +/ , '' )
32+ Write-Host '****************************** Configuring system settings'
33+ $langList = New-WinUserLanguageList 'en-US'
34+ $langList[0].InputMethodTips.Clear()
35+ $langList[0].InputMethodTips.Add('0410:00000410')
36+ Set-WinUserLanguageList $langList -Force
37+ Write-Host '****************************** Updating PowerShell help'
38+ Update-Help -Force -ErrorAction Ignore
39+ Write-Host '****************************** Updating Guest Additions'
40+ Invoke-WebRequest -Uri 'http://download.virtualbox.org/virtualbox/LATEST.TXT' -OutFile "$env:SYSTEMROOT\\ Temp\\ vbga-latest-version.txt"
41+ $vbgaLatestVersion = Get-Content "$env:SYSTEMROOT\\ Temp\\ vbga-latest-version.txt"
42+ Remove-Item "$env:SYSTEMROOT\\ Temp\\ vbga-latest-version.txt"
43+ Invoke-WebRequest -Uri "http://download.virtualbox.org/virtualbox/$vbgaLatestVersion/VBoxGuestAdditions_$vbgaLatestVersion.iso" -OutFile "$env:SYSTEMROOT\\ Temp\\ VBoxGuestAdditions.iso"
44+ $mountResult = Mount-DiskImage -ImagePath $env:SYSTEMROOT\\ Temp\\ VBoxGuestAdditions.iso -PassThru
45+ $mountedIsoDrive = (Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Name -eq ($mountResult | Get-Volume).DriveLetter }).Root
46+ Set-Location (Join-Path -Path $mountedIsoDrive -ChildPath 'cert')
47+ .\\ VBoxCertUtil.exe 'remove-trusted-publisher' 'vbox-sha1.cer' | Out-Null
48+ .\\ VBoxCertUtil.exe 'remove-trusted-publisher' 'vbox-sha256.cer' | Out-Null
49+ .\\ VBoxCertUtil.exe 'remove-trusted-publisher' 'vbox-sha256-r3.cer' | Out-Null
50+ .\\ VBoxCertUtil.exe 'add-trusted-publisher' 'vbox*.cer' '--root' 'vbox*.cer' | Out-Null
51+ Set-Location $mountedIsoDrive
52+ Start-Process -NoNewWindow -Wait -FilePath .\\ VBoxWindowsAdditions.exe -ArgumentList /S, /with_wddm, /xres=1024, /yres=768
53+ $guestAdditionVersion = & "C:\\ Program Files\\ Oracle\\ VirtualBox Guest Additions\\ VBoxControl.exe" -v
54+ Write-Host "***** Updated Guest Additions to version $guestAdditionVersion"
55+ Dismount-DiskImage -ImagePath "$env:SYSTEMROOT\\ Temp\\ VBoxGuestAdditions.iso"
56+ Remove-Item "$env:SYSTEMROOT\\ Temp\\ VBoxGuestAdditions.iso"
57+ Write-Host '****************************** Installing Docker'
58+ Write-Host '***** Installing Docker Engine'
59+ Install-PackageProvider NuGet -Force
60+ Install-Module DockerProvider -Force
61+ Install-Package Docker -ProviderName DockerProvider -Force
62+ Write-Host '***** Enabling named pipe and HTTP Docker APIs'
63+ Write-Host "Usage: Invoke-WebRequest -Uri 'http://localhost:4243/images/json' -UseBasicParsing"
64+ New-NetFirewallRule -DisplayName 'winrm' -Direction Inbound -LocalPort 5985 -Protocol TCP -Action Allow -Enabled True
65+ New-NetFirewallRule -DisplayName 'rdp' -Direction Inbound -LocalPort 3389 -Protocol TCP -Action Allow -Enabled True
66+ New-NetFirewallRule -DisplayName 'docker-http-api' -Direction Inbound -LocalPort 4243 -Protocol TCP -Action Allow -Enabled True
67+ New-NetFirewallRule -DisplayName 'rmq-mqttWithoutTls' -Direction Inbound -LocalPort 1883 -Protocol TCP -Action Allow -Enabled True
68+ New-NetFirewallRule -DisplayName 'rmq-epmd' -Direction Inbound -LocalPort 4369 -Protocol TCP -Action Allow -Enabled True
69+ New-NetFirewallRule -DisplayName 'rmq-amqpWithTls' -Direction Inbound -LocalPort 5671 -Protocol TCP -Action Allow -Enabled True
70+ New-NetFirewallRule -DisplayName 'rmq-amqpWithoutTls' -Direction Inbound -LocalPort 5672 -Protocol TCP -Action Allow -Enabled True
71+ New-NetFirewallRule -DisplayName 'rmq-mqttWithTls' -Direction Inbound -LocalPort 8883 -Protocol TCP -Action Allow -Enabled True
72+ New-NetFirewallRule -DisplayName 'rmq-managementWithTls' -Direction Inbound -LocalPort 15671 -Protocol TCP -Action Allow -Enabled True
73+ New-NetFirewallRule -DisplayName 'rmq-managementWithoutTls' -Direction Inbound -LocalPort 15672 -Protocol TCP -Action Allow -Enabled True
74+ New-NetFirewallRule -DisplayName 'rmq-stompOverWebsockets' -Direction Inbound -LocalPort 15674 -Protocol TCP -Action Allow -Enabled True
75+ New-NetFirewallRule -DisplayName 'rmq-mqttOverWebsockets' -Direction Inbound -LocalPort 15675 -Protocol TCP -Action Allow -Enabled True
76+ New-NetFirewallRule -DisplayName 'rmq-erlangDistribution' -Direction Inbound -LocalPort 25672 -Protocol TCP -Action Allow -Enabled True
77+ New-NetFirewallRule -DisplayName 'rmq-stompWithoutTls' -Direction Inbound -LocalPort 61613 -Protocol TCP -Action Allow -Enabled True
78+ New-NetFirewallRule -DisplayName 'rmq-stompWithTls' -Direction Inbound -LocalPort 61614 -Protocol TCP -Action Allow -Enabled True
79+ New-Item -Force -Type File -Path 'C:\\ ProgramData\\ docker\\ config\\ daemon.json' -Value '{ "hosts": ["npipe://", "tcp://0.0.0.0:4243"] }'
80+ SHELL
81+ end
82+ config . vm . provision :reload
83+ end
0 commit comments