Commit 4a6725d7 authored by Stefan Scherer's avatar Stefan Scherer

Improve docker installation

parent 6b7863c1
#!/bin/bash
packer build --only=vmware-iso --var iso_url=~/packer_cache/14300.1000.160324-1723.RS1_RELEASE_SVC_SERVER_OEMRET_X64FRE_EN-US.ISO windows_2016_docker.json
Write-Host "WARNING: DO NOT USE DOCKER IN PRODUCTION WITHOUT TLS"
Write-Host "Enabling Docker unsecure port 2375"
Write-Host "Enabling Docker insecure port 2375"
if (!(Get-NetFirewallRule | where {$_.Name -eq "DockerUnsecure2375"})) {
New-NetFirewallRule -Name "DockerUnsecure2375" -DisplayName "Docker unsecure on TCP/2375" -Protocol tcp -LocalPort 2375 -Action Allow -Enabled True
if (!(Get-NetFirewallRule | where {$_.Name -eq "Dockerinsecure2375"})) {
New-NetFirewallRule -Name "Dockerinsecure2375" -DisplayName "Docker insecure on TCP/2375" -Protocol tcp -LocalPort 2375 -Action Allow -Enabled True
}
Write-Host "Enabling Docker to listen on unsecure port 2375"
Write-Host "Enabling Docker to listen on insecure port 2375"
cp C:\ProgramData\docker\runDockerDaemon.cmd C:\ProgramData\docker\runDockerDaemon.cmd.bak
cat C:\ProgramData\docker\runDockerDaemon.cmd.bak | %{$_ -replace '^docker daemon -D -b "Virtual Switch"$','docker daemon -D -b "Virtual Switch" -H 0.0.0.0:2375'} | Set-Content C:\ProgramData\docker\runDockerDaemon.cmd
......
Sleep 2
# https://msdn.microsoft.com/virtualization/windowscontainers/quick_start/inplace_setup
wget -uri https://aka.ms/tp4/Install-ContainerHost -OutFile C:\Install-ContainerHost.ps1
# https://msdn.microsoft.com/virtualization/windowscontainers/deployment/deployment
wget https://aka.ms/tp5/Update-Container-Host -OutFile c:\update-containerhost.ps1 -UseBasicParsing
Install-PackageProvider ContainerImage -Force
# create a Task Scheduler task which is also able to run in battery mode due
# to host notebooks working in battery mode.
......@@ -97,28 +100,13 @@ if (Test-Path a:\oracle-cert.cer) {
$installOptions = "-HyperV"
}
# Download latest nightly build of docker engine
$wantNightlyDocker = $false
if ($wantNightlyDocker) {
$ExeFile = "C:\Users\vagrant\Downloads\docker.exe"
wget -o $ExeFile https://master.dockerproject.org/windows/amd64/docker.exe
Run-Interactive -commandline "C:\Install-ContainerHost.ps1 $installOptions -DockerPath $ExeFile | Tee-Object -FilePath C:\progress.txt"
} else {
Run-Interactive -commandline "C:\Install-ContainerHost.ps1 $installOptions | Tee-Object -FilePath C:\progress.txt"
}
if ($installOptions) {
# install the windowsservercore image as well (w/o the -HyperV switch)
Run-Interactive -commandline "C:\Install-ContainerHost.ps1 -SkipDocker | Tee-Object -FilePath C:\progress.txt"
}
Run-Interactive -commandline "C:\update-containerhost.ps1 | Tee-Object -FilePath C:\progress.txt"
# tag the base images to latest if the tag got lost
if ("$(docker images windowsservercore:latest | wc -l)" -eq "1") {
docker tag windowsservercore:10.0.10586.0 windowsservercore:latest
}
if ($installOptions) {
if ("$(docker images nanoserver:latest | wc -l)" -eq "1") {
docker tag nanoserver:10.0.10586.0 nanoserver:latest
}
Run-Interactive -commandline "Install-ContainerImage -Name WindowsServerCore | Tee-Object -FilePath C:\progress.txt"
if (Test-Path a:\oracle-cert.cer) {
Write-Host "Skipping NanoServer container image"
} else {
Run-Interactive -commandline "Install-ContainerImage -Name NanoServer | Tee-Object -FilePath C:\progress.txt"
}
# https://msdn.microsoft.com/virtualization/windowscontainers/quick_start/manage_docker
restart-service docker
# for debugging
# wait until a file has been removed from desktop
$file = "C:\users\vagrant\Desktop\delete-to-continue.txt"
if (-Not (Test-Path $file)) {
Write-Host "Remove me" | Out-File $file
}
Write-Host "Wait until someone removes $file"
while (Test-Path $file) {
Sleep 1
}
Write-Host "Done waiting!"
......@@ -102,7 +102,7 @@
"type": "powershell",
"scripts": [
"./scripts/install-docker.ps1",
"./scripts/enable-docker-unsecure.ps1"
"./scripts/enable-docker-insecure.ps1"
]
},
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment