@@ -20,20 +20,22 @@ Function Get-DockerWincredHash
2020}
2121# endregion
2222
23- Write-Host " Get latest release of Docker CE "
23+ Write-Host " Get latest Moby release "
2424$mobyLatestReleaseVersion = (Invoke-RestMethod - Uri " https://api.github.com/repos/moby/moby/releases/latest" ).tag_name.Trim(" v" )
2525$dockerceUrl = " https://download.docker.com/win/static/stable/x86_64/"
2626$dockerceBinaries = Invoke-WebRequest - Uri $dockerceUrl - UseBasicParsing
2727
28- Write-Host " Checking $mobyLatestReleaseVersion version"
28+ Write-Host " Check Moby version $mobyLatestReleaseVersion "
2929$mobyRelease = $dockerceBinaries.Links.href -match " ${mobyLatestReleaseVersion} \.zip" | Select-Object - Last 1
3030if (-not $mobyRelease ) {
3131 Write-Host " Release not found for $mobyLatestRelease version"
32- $versions = [regex ]::Matches($dockerceBinaries.Links.href , " docker-(\d+\.\d+\.\d+)\.zip" ) | Sort-Object {[version ]$_.Groups [1 ].Value}
32+ $versions = [regex ]::Matches($dockerceBinaries.Links.href , " docker-(\d+\.\d+\.\d+)\.zip" ) | Sort-Object { [version ]$_.Groups [1 ].Value }
3333 $mobyRelease = $versions | Select-Object - ExpandProperty Value - Last 1
3434 Write-Host " Found $mobyRelease "
3535}
3636$mobyReleaseUrl = $dockerceUrl + $mobyRelease
37+
38+ Write-Host " Install Moby $mobyRelease ..."
3739$mobyArchivePath = Start-DownloadWithRetry - Url $mobyReleaseUrl - Name $mobyRelease
3840Expand-Archive - Path $mobyArchivePath - DestinationPath $env: TEMP
3941$dockerPath = " $env: TEMP \docker\docker.exe"
@@ -43,6 +45,10 @@ Write-Host "Install Docker CE"
4345$instScriptUrl = " https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1"
4446$instScriptPath = Start-DownloadWithRetry - Url $instScriptUrl - Name " install-docker-ce.ps1"
4547& $instScriptPath - DockerPath $dockerPath - DockerDPath $dockerdPath
48+ if ($LastExitCode -ne 0 ) {
49+ Write-Host " Docker installation failed with exit code $LastExitCode "
50+ exit $exitCode
51+ }
4652
4753# Fix AZ CLI DOCKER_COMMAND_ERROR
4854# cli.azure.cli.command_modules.acr.custom: Could not run 'docker.exe' command.
@@ -69,9 +75,9 @@ $distributor_file_hash = Get-DockerWincredHash -Release $dockerCredLatestRelease
6975$local_file_hash = (Get-FileHash - Path ' C:\Windows\System32\docker-credential-wincred.exe' - Algorithm SHA256).Hash
7076
7177if ($local_file_hash -ne $distributor_file_hash ) {
72- Write-Host " hash must be equal to: ${distributor_file_hash} "
73- Write-Host " actual hash is: ${local_file_hash} "
74- throw ' Checksum verification failed, please rerun install'
78+ Write-Host " hash must be equal to: ${distributor_file_hash} "
79+ Write-Host " actual hash is: ${local_file_hash} "
80+ throw ' Checksum verification failed, please rerun install'
7581}
7682# endregion
7783
@@ -87,4 +93,4 @@ foreach ($dockerImage in $dockerImages) {
8793 }
8894}
8995
90- Invoke-PesterTests - TestFile " Docker"
96+ Invoke-PesterTests - TestFile " Docker"
0 commit comments