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

前端 未结 19 1976
时光取名叫无心
时光取名叫无心 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:04

    I have done this thing when I have to implement a task in which if user somehow type the wrong tag then we have to give the list of all the tag present in the repo(Docker repo) present in the register. So I have code in batch Script.

    
    
    @echo off
    
    docker login --username=xxxx --password=xxxx
    docker pull %1:%2
    
    IF NOT %ERRORLEVEL%==0 (
    echo "Specified Version is Not Found "
    echo "Available Version for this image is :"
    for /f %%i in (' curl -s -H "Content-Type:application/json" -X POST -d "{\"username\":\"user\",\"password\":\"password\"}" https://hub.docker.com/v2/users/login ^|jq -r .token ') do set TOKEN=%%i
    curl -sH "Authorization: JWT %TOKEN%" "https://hub.docker.com/v2/repositories/%1/tags/" | jq .results[].name
    )
    

    So in this we can give arguments to out batch file like:

    Dockerfile java version7 

提交回复
热议问题