How can I list all tags for a Docker image on a remote registry?

前端 未结 19 1888
时光取名叫无心
时光取名叫无心 2020-12-04 04:46

How can I list all tags of a Docker image on a remote Docker registry using the CLI (preferred) or curl?

Preferably without pulling all versions from the remote regi

相关标签:
19条回答
  • 2020-12-04 05:30

    Here's a Powershell script I wrote for Windows. Handles v1 and v2 repos:

    Get-DockerImageVersions.ps1:

    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 tags
      $tags.tags
    } else {
      $tags = $resp | select name
      $tags.name
    }
    
    0 讨论(0)
提交回复
热议问题