mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
[Windows] Exit on Docker installation failure (#8473)
This commit is contained in:
committed by
GitHub
parent
dfc4f9c7af
commit
e2c5aaf70a
@@ -20,20 +20,22 @@ Function Get-DockerWincredHash
|
||||
}
|
||||
#endregion
|
||||
|
||||
Write-Host "Get latest release of Docker CE"
|
||||
Write-Host "Get latest Moby release"
|
||||
$mobyLatestReleaseVersion = (Invoke-RestMethod -Uri "https://api.github.com/repos/moby/moby/releases/latest").tag_name.Trim("v")
|
||||
$dockerceUrl = "https://download.docker.com/win/static/stable/x86_64/"
|
||||
$dockerceBinaries = Invoke-WebRequest -Uri $dockerceUrl -UseBasicParsing
|
||||
|
||||
Write-Host "Checking $mobyLatestReleaseVersion version"
|
||||
Write-Host "Check Moby version $mobyLatestReleaseVersion"
|
||||
$mobyRelease = $dockerceBinaries.Links.href -match "${mobyLatestReleaseVersion}\.zip" | Select-Object -Last 1
|
||||
if (-not $mobyRelease) {
|
||||
Write-Host "Release not found for $mobyLatestRelease version"
|
||||
$versions = [regex]::Matches($dockerceBinaries.Links.href, "docker-(\d+\.\d+\.\d+)\.zip") | Sort-Object {[version]$_.Groups[1].Value}
|
||||
$versions = [regex]::Matches($dockerceBinaries.Links.href, "docker-(\d+\.\d+\.\d+)\.zip") | Sort-Object { [version]$_.Groups[1].Value }
|
||||
$mobyRelease = $versions | Select-Object -ExpandProperty Value -Last 1
|
||||
Write-Host "Found $mobyRelease"
|
||||
}
|
||||
$mobyReleaseUrl = $dockerceUrl + $mobyRelease
|
||||
|
||||
Write-Host "Install Moby $mobyRelease..."
|
||||
$mobyArchivePath = Start-DownloadWithRetry -Url $mobyReleaseUrl -Name $mobyRelease
|
||||
Expand-Archive -Path $mobyArchivePath -DestinationPath $env:TEMP
|
||||
$dockerPath = "$env:TEMP\docker\docker.exe"
|
||||
@@ -43,6 +45,10 @@ Write-Host "Install Docker CE"
|
||||
$instScriptUrl = "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1"
|
||||
$instScriptPath = Start-DownloadWithRetry -Url $instScriptUrl -Name "install-docker-ce.ps1"
|
||||
& $instScriptPath -DockerPath $dockerPath -DockerDPath $dockerdPath
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Host "Docker installation failed with exit code $LastExitCode"
|
||||
exit $exitCode
|
||||
}
|
||||
|
||||
# Fix AZ CLI DOCKER_COMMAND_ERROR
|
||||
# cli.azure.cli.command_modules.acr.custom: Could not run 'docker.exe' command.
|
||||
@@ -69,9 +75,9 @@ $distributor_file_hash = Get-DockerWincredHash -Release $dockerCredLatestRelease
|
||||
$local_file_hash = (Get-FileHash -Path 'C:\Windows\System32\docker-credential-wincred.exe' -Algorithm SHA256).Hash
|
||||
|
||||
if ($local_file_hash -ne $distributor_file_hash) {
|
||||
Write-Host "hash must be equal to: ${distributor_file_hash}"
|
||||
Write-Host "actual hash is: ${local_file_hash}"
|
||||
throw 'Checksum verification failed, please rerun install'
|
||||
Write-Host "hash must be equal to: ${distributor_file_hash}"
|
||||
Write-Host "actual hash is: ${local_file_hash}"
|
||||
throw 'Checksum verification failed, please rerun install'
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user