Skip to content

Instantly share code, notes, and snippets.

@so0k
Last active June 27, 2020 14:19
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save so0k/b59382ea7fd959cf7040 to your computer and use it in GitHub Desktop.
Save so0k/b59382ea7fd959cf7040 to your computer and use it in GitHub Desktop.
Query a docker registry v2/_catalog endpoint from powershell
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
$Filter=".*",
#TODO: handle https & no basic auth as well..
$RegistryEndpoint = "registry.mysite.com",
$UserName = "user",
$Password = "password"
)
#encode credentials to Base64String
$AuthString = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($UserName):$($Password)"))
$Result = (Invoke-RestMethod -Uri "http://$RegistryEndpoint/v2/_catalog" -Method Get -Headers @{ Authorization = "Basic $AuthString";}).repositories -Match $Filter
Write-Host -ForegroundColor Green ("found {0} images:" -f $Result.count)
$Result | % {
$image=$_
$image
(irm -uri "http://$RegistryEndpoint/v2/$image/tags/list" -Method Get -Headers @{ Authorization = "Basic $AuthString";}).tags | % {
$tag=$_
" docker pull $RegistryEndpoint/${image}:${tag}"
}
}
@so0k
Copy link
Author

so0k commented Jul 29, 2015

Sample usage from powershell commandline
Sample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment