From 6cc874356c0341862bd695e13db58ce7c1cc72e4 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Thu, 6 Oct 2022 20:37:12 +0200 Subject: [PATCH] [Windows] Install latest release of Docker CE (#6360) --- .../win/scripts/Installers/Install-Docker.ps1 | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-Docker.ps1 b/images/win/scripts/Installers/Install-Docker.ps1 index 28efff98..ce28bdb6 100644 --- a/images/win/scripts/Installers/Install-Docker.ps1 +++ b/images/win/scripts/Installers/Install-Docker.ps1 @@ -5,10 +5,29 @@ ## can continue. ################################################################################ +Write-Host "Get latest release of Docker CE" +$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" +$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} + $mobyRelease = $versions | Select-Object -ExpandProperty Value -Last 1 + Write-Host "Found $mobyRelease" +} +$mobyReleaseUrl = $dockerceUrl + $mobyRelease +$mobyArchivePath = Start-DownloadWithRetry -Url $mobyReleaseUrl -Name $mobyRelease +Expand-Archive -Path $mobyArchivePath -DestinationPath $env:TEMP +$dockerPath = "$env:TEMP\docker\docker.exe" +$dockerdPath = "$env:TEMP\docker\dockerd.exe" + 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 +& $instScriptPath -DockerPath $dockerPath -DockerDPath $dockerdPath # Fix AZ CLI DOCKER_COMMAND_ERROR # cli.azure.cli.command_modules.acr.custom: Could not run 'docker.exe' command.