2019-11-19 16:06:10 +00:00
|
|
|
Set-StrictMode -Version latest
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
|
|
$RunningAsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
|
|
|
|
if (!$RunningAsAdmin) {
|
|
|
|
Write-Error "Must be executed in Administrator level shell."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Force TLS1.2
|
|
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
|
|
|
|
|
|
Try {
|
|
|
|
Write-Output "Installing containers feature."
|
2020-11-09 18:29:40 +00:00
|
|
|
Install-WindowsFeature -Name Containers -ErrorAction Stop
|
2019-11-19 16:06:10 +00:00
|
|
|
|
|
|
|
Write-Output "Creating user for Docker."
|
|
|
|
net localgroup docker /add
|
|
|
|
net localgroup docker $env:USERNAME /add
|
|
|
|
|
|
|
|
Write-Output "Installing Docker."
|
2020-11-09 18:29:40 +00:00
|
|
|
|
|
|
|
# Getting an error at this step? Check for their "status page" at:
|
|
|
|
# https://github.com/PowerShell/PowerShellGallery/blob/master/psgallery_status.md
|
|
|
|
Set-PSRepository -InstallationPolicy Trusted -Name PSGallery -ErrorAction Stop
|
|
|
|
|
|
|
|
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force -ErrorAction Stop
|
|
|
|
Install-Package -Name docker -ProviderName DockerMsftProvider -Force -ErrorAction Stop
|
2019-11-19 16:06:10 +00:00
|
|
|
|
|
|
|
} Catch {
|
2020-11-09 18:29:40 +00:00
|
|
|
Write-Output "Failed to install Docker."
|
|
|
|
Write-Output $_
|
2019-11-19 16:06:10 +00:00
|
|
|
$host.SetShouldExit(-1)
|
|
|
|
throw
|
|
|
|
} Finally {
|
|
|
|
# clean up by re-securing this package repo
|
|
|
|
Set-PSRepository -InstallationPolicy Untrusted -Name PSGallery
|
|
|
|
}
|
|
|
|
|
|
|
|
Write-Output "Installed Docker."
|