Skip to content

Instantly share code, notes, and snippets.

@Meir017
Created January 23, 2024 20:44
Show Gist options
  • Save Meir017/bfe7e44ab53c24d20564ac3ce61e1e9a to your computer and use it in GitHub Desktop.
Save Meir017/bfe7e44ab53c24d20564ac3ce61e1e9a to your computer and use it in GitHub Desktop.
download docker images to TAR files
function download-docker-image {
param(
[Parameter(Mandatory=$true)]
[string]$image,
[Parameter(Mandatory=$true)]
[string]$tag,
[Parameter(Mandatory=$true)]
[string]$output
)
$imageWithTag = "$($image):$($tag)"
$outputFile = "$($output)-$($tag).tar"
if (Test-Path $outputFile) {
Write-Host "Skipping save of " -NoNewline
Write-Host $imageWithTag -ForegroundColor Yellow -NoNewline
Write-Host " to " -NoNewline
Write-Host $outputFile -ForegroundColor Yellow -NoNewline
Write-Host " file already exists."
return
}
Write-Host "Downloading " -NoNewline
Write-Host $imageWithTag -ForegroundColor Cyan -NoNewline
Write-Host " to " -NoNewline
Write-Host $outputFile -ForegroundColor Cyan
$StartTime = Get-Date
do {
docker pull $imageWithTag
} until (
$LASTEXITCODE -eq 0
)
$EndTime = Get-Date
$TimeTaken = New-TimeSpan -Start $StartTime -End $EndTime
Write-Host "Pulled $imageWithTag in $TimeTaken" -ForegroundColor Green
$StartTime = Get-Date
if (!(Test-Path $outputFile)) {
docker save --output $outputFile $imageWithTag
$EndTime = Get-Date
$TimeTaken = New-TimeSpan -Start $StartTime -End $EndTime
Write-Host "Saved $imageWithTag to $outputFile in $TimeTaken" -ForegroundColor Green
} else {
Write-Host "Skipping save of " -NoNewline
Write-Host $imageWithTag -ForegroundColor Yellow -NoNewline
Write-Host " to " -NoNewline
Write-Host $outputFile -ForegroundColor Yellow
}
}
$DotnetVersions = @(
"v1.20.2"
"v1.20.2-focal",
"v1.21.0",
"v1.21.0-focal",
"v1.22.0",
"v1.22.0-focal",
"v1.23.0",
"v1.23.0-focal",
"v1.24.1",
"v1.24.1-focal",
"v1.25.0",
"v1.25.0-focal",
"v1.26.0",
"v1.26.0-focal",
"v1.27.2",
"v1.27.2-focal",
"v1.28.0",
"v1.28.0-focal",
"v1.29.0",
"v1.29.0-focal",
"v1.30.0",
"v1.30.0-focal",
"v1.31.1",
"v1.31.1-focal",
"v1.32.0",
"v1.32.0-jammy",
"v1.32.0-focal",
"v1.33.0",
"v1.33.0-jammy",
"v1.33.0-focal",
"v1.34.0",
"v1.34.0-jammy",
"v1.34.0-focal",
"v1.35.0",
"v1.35.0-jammy",
"v1.35.0-focal",
"v1.36.0",
"v1.36.0-jammy",
"v1.36.0-focal",
"v1.37.1",
"v1.37.1-jammy",
"v1.37.1-focal",
"v1.38.0",
"v1.38.0-jammy",
"v1.38.0-focal"
)
$NodejsVersions = @(
"v1.16.3",
"v1.16.3-bionic",
"v1.16.3-focal",
"v1.17.2",
"v1.17.2-bionic",
"v1.17.2-focal",
"v1.18.1",
"v1.18.1-bionic",
"v1.18.1-focal",
"v1.19.2",
"v1.19.2-bionic",
"v1.19.2-focal",
"v1.20.2",
"v1.20.2-bionic",
"v1.20.2-focal",
"v1.21.1",
"v1.21.1-bionic",
"v1.21.1-focal",
"v1.22.2",
"v1.22.2-bionic",
"v1.22.2-focal",
"v1.23.4",
"v1.23.4-bionic",
"v1.23.4-focal",
"v1.23.4-jammy",
"v1.24.2",
"v1.24.2-bionic",
"v1.24.2-focal",
"v1.24.2-jammy",
"v1.25.2",
"v1.25.2-bionic",
"v1.25.2-focal",
"v1.25.2-jammy",
"v1.26.1",
"v1.26.1-bionic",
"v1.26.1-focal",
"v1.26.1-jammy",
"v1.27.1",
"v1.27.1-bionic",
"v1.27.1-focal",
"v1.27.1-jammy",
"v1.28.1",
"v1.28.1-bionic",
"v1.28.1-focal",
"v1.28.1-jammy",
"v1.29.2",
"v1.29.2-focal",
"v1.29.2-jammy",
"v1.29.2-vrt",
"v1.30.0",
"v1.30.0-focal",
"v1.30.0-jammy",
"v1.30.0-vrt",
"v1.31.2",
"v1.31.2-focal",
"v1.31.2-jammy",
"v1.32.3",
"v1.32.3-focal",
"v1.32.3-jammy",
"v1.33.0",
"v1.33.0-focal",
"v1.33.0-jammy",
"v1.34.3",
"v1.34.3-focal",
"v1.34.3-jammy",
"v1.35.1",
"v1.35.1-focal",
"v1.35.1-jammy",
"v1.36.2",
"v1.36.2-focal",
"v1.36.2-jammy",
"v1.37.1",
"v1.37.1-focal",
"v1.37.1-jammy",
"v1.38.1",
"v1.38.1-focal",
"v1.38.1-jammy",
"v1.39.0",
"v1.39.0-focal",
"v1.39.0-jammy"
)
$SeleniumNodeChromeVersions = @(
'97.0',
'98.0',
'99.0',
'100.0',
'101.0',
'102.0',
'103.0',
'104.0',
'105.0',
'106.0',
'107.0',
'108.0',
'109.0',
'110.0',
'111.0',
'112.0',
'113.0',
'114.0',
'115.0',
'116.0',
'117.0',
'118.0'
)
$SeleniumHubVersions = @(
'4.1.2-20220131', # chrome 97.0
'4.1.2-20220217', # chrome 98.0
'4.1.3-20220327', # chrome 99.0
'4.1.3-20220405', # chrome 100.0
'4.1.4-20220427', # chrome 101.0
'4.2.2-20220609', # chrome 102.0
'4.3.0-20220726', # chrome 103.0
'4.4.0-20220812', # chrome 104.0
'4.4.0-20220831', # chrome 105.0
'4.5.3-20221024', # chrome 106.0
'4.6.0-20221104', # chrome 107.0
'4.7.2-20221219', # chrome 108.0
'4.8.0-20230202', # chrome 109.0
'4.8.1-20230306', # chrome 110.0
'4.8.3-20230404', # chrome 111.0
'4.9.0-20230421', # chrome 112.0
'4.9.1-20230508', # chrome 113.0
'4.10.0-20230614', # chrome 114.0
'4.11.0-20230801', # chrome 115.0
'4.12.1-20230912', # chrome 116.0
'4.13.0-20231004', # chrome 117.0
'4.14.1-20231020' # chrome 118.0
)
$SeleniumGridVersions = @(
'4.13.0-20231004', # chrome 117.0
'4.14.1-20231020' # chrome 118.0
)
$items = @(
# @{ imageName = 'mcr.microsoft.com/playwright/dotnet'; outputName = 'playwright-dotnet'; versions = $DotnetVersions },
# @{ imageName = 'mcr.microsoft.com/playwright'; outputName = 'playwright'; versions = $NodejsVersions },
# @{ imageName = 'selenium/node-chrome'; outputName = 'selenium-node-chrome'; versions = $SeleniumNodeChromeVersions },
# @{ imageName = 'selenium/hub'; outputName = 'selenium-hub'; versions = $SeleniumHubVersions },
# @{ imageName = 'selenium/router'; outputName = 'selenium-router'; versions = $SeleniumGridVersions },
# @{ imageName = 'selenium/distributor'; outputName = 'selenium-distributor'; versions = $SeleniumGridVersions },
# @{ imageName = 'selenium/event-bus'; outputName = 'selenium-event-bus'; versions = $SeleniumGridVersions },
# @{ imageName = 'selenium/sessions'; outputName = 'selenium-sessions'; versions = $SeleniumGridVersions },
# @{ imageName = 'selenium/session-queue'; outputName = 'selenium-session-queue'; versions = $SeleniumGridVersions }
@{ imageName = 'mcr.microsoft.com/dotnet/sdk'; outputName = 'dotnet-sdk'; versions = @( '7.0', '8.0' ) },
@{ imageName = 'mcr.microsoft.com/dotnet/aspnet'; outputName = 'dotnet-aspnet'; versions = @( '7.0', '8.0' ) },
@{ imageName = 'mcr.microsoft.com/dotnet/monitor'; outputName = 'dotnet-monitor'; versions = @( '7.0', '8.0' ) },
@{ imageName = 'registry.access.redhat.com/ubi8/dotnet-70-runtime'; outputName = 'dotnet-ubi8-7-runtime'; versions = @( '7.0' ) },
@{ imageName = 'registry.access.redhat.com/ubi8/dotnet-80-runtime'; outputName = 'dotnet-ubi8-8-runtime'; versions = @( '8.0' ) }
)
foreach ($item in $items) {
$imageName = $item.imageName
$outputName = $item.outputName
$versions = $item.versions
foreach ($version in $versions) {
download-docker-image -image $imageName -tag $version -output $outputName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment