Skip to content

Instantly share code, notes, and snippets.

@jlouros
Created January 20, 2020 17:42
Show Gist options
  • Save jlouros/af5d3d4bd0b51b68851fd427ecd7b5fb to your computer and use it in GitHub Desktop.
Save jlouros/af5d3d4bd0b51b68851fd427ecd7b5fb to your computer and use it in GitHub Desktop.
get all tags for a docker image on a remote registry
param (
[Parameter (Mandatory=$true)]$ImageName,
[Parameter (Mandatory=$false)]$RegistryURL
)
if (!$RegistryURL)
{
$RegistryURL = "https://registry.hub.docker.com/v1/repositories"
}
$list = ""
if ($RegistryURL -like "*v2*")
{
$list = "/list"
}
$URL = "$RegistryURL/$ImageName/tags$list"
write-debug $URL
$resp = Invoke-WebRequest -UseBasicParsing $URL | ConvertFrom-Json
if ($RegistryURL -like "*v2*")
{
$tags = $resp | Select-Object tags
$tags.tags
} else {
$tags = $resp | Select-Object name
$tags.name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment