install-docker.ps1 2.07 KB
Newer Older
1
# use docker_provider:  "ee", "ce", "master" or ""
2
$docker_provider = "ee"
Stefan Scherer's avatar
Stefan Scherer committed
3
$docker_version = "18-09-6"
4 5 6 7 8 9 10
if (Test-Path env:docker_provider) {
  $docker_provider = $env:docker_provider  
}
if (Test-Path env:docker_version) {
  $docker_version = $env:docker_version  
}

11
$ProgressPreference = 'SilentlyContinue'
12
if ($docker_provider -eq "ce") {
13
  $zip_url = $("https://download.docker.com/win/static/edge/x86_64/docker-{0}-ce.zip" -f $docker_version)
14
} elseif ($docker_provider -eq "ee") {
15 16 17 18 19 20 21
  $zip_url = $("https://dockermsft.blob.core.windows.net/dockercontainer/docker-{0}.zip" -f $docker_version)
} elseif ($docker_provider -eq "master") {
  $docker_version = "master"
  $zip_url = "https://master.dockerproject.com/windows/x86_64/docker.zip"
}

if ($zip_url) {
22 23 24
  Set-ExecutionPolicy Bypass -scope Process
  New-Item -Type Directory -Path "$($env:ProgramFiles)\docker"
  Write-Output "Downloading docker $docker_version ..."
25
  wget -outfile $env:TEMP\docker.zip $zip_url
26
  Expand-Archive -Path $env:TEMP\docker.zip -DestinationPath $env:TEMP -Force
27
  copy $env:TEMP\docker\*.* $env:ProgramFiles\docker
28
  Remove-Item $env:TEMP\docker.zip
Stefan Scherer's avatar
Stefan Scherer committed
29
  Remove-Item -Recurse $env:TEMP\docker
30 31 32
  [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$($env:ProgramFiles)\docker", [EnvironmentVariableTarget]::Machine)
  $env:Path = $env:Path + ";$($env:ProgramFiles)\docker"
  Write-Output "Registering docker service ..."
33 34
  . dockerd --register-service
} else {
Stefan Scherer's avatar
Stefan Scherer committed
35
  Write-Output "Install-PackageProvider ..."
36
  Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Stefan Scherer's avatar
Stefan Scherer committed
37
  Write-Output "Install-Module $docker_provider ..."
38 39
  Install-Module -Name $docker_provider -Repository PSGallery -Force
  Write-Output "Install-Package docker version $docker_version ..."
40 41
  Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
  $ErrorActionStop = 'SilentlyContinue'
Stefan Scherer's avatar
Stefan Scherer committed
42
  Install-Package -Name docker -ProviderName $docker_provider -RequiredVersion $docker_version -Force
43 44 45
  Set-PSRepository -InstallationPolicy Untrusted -Name PSGallery  
}

46
$ErrorActionPreference = 'Stop'
47
Write-Output "Starting docker ..."
48
Start-Service docker