How to view all tags for a Docker image in a remote registry?

I would like to know how to list all the tags of a Docker image in a remote Docker registry using the CLI (preferred) or curl? Preferably, without pulling all the versions from the remote registry, I just want to list the tags.

+135
docker
Feb 04 '15 at 11:22
source share
18 answers

I got an answer from here . Thank you very much! :)

Just a single line script: (find all Debian tags)

wget -q https://registry.hub.docker.com/v1/repositories/debian/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' 



UPDATE Thanks for the advice @degelf. Here is a shell script.

 #!/bin/bash if [ $# -lt 1 ] then cat << HELP dockertags -- list all tags for a Docker image on a remote registry. EXAMPLE: - list all tags for ubuntu: dockertags ubuntu - list all php tags containing apache: dockertags php apache HELP fi image="$1" tags='wget -q https://registry.hub.docker.com/v1/repositories/${image}/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'' if [ -n "$2" ] then tags=' echo "${tags}" | grep "$2" ' fi echo "${tags}" 

You can simply create a new file name, dockertags , in / usr / local / bin (or add PATH env to your .bashrc / .zshrc ) and put this code in it. Then add permissions to the executable ( chmod +x dockertags ).

Using:

dockertags ubuntu ---> list all ubuntu tags

dockertags php apache ---> list all php php tags containing 'apache'

+116
Sep 12 '16 at 16:00
source share
β€” -

As with Docker Registry V2, a simple GET sufficient:

 GET /v2/<name>/tags/list 

See docs for more details.

+64
Sep 14 '16 at 8:12
source share

I managed to get it to work using curl:

 curl -u <username>:<password> https://tutum.co/v1/repositories/<username>/<image_name>/tags 

Please note that image_name should not contain user information, etc. For example, if you click on an image named tutum.co/username/x , then image_name should be x .

+15
Feb 06 '15 at 17:50
source share

If you want to use the docker registry v2 API, it lists the tags by page. To list all image tags, you can add a large page_size parameter to the URL, for example.

 curl -L -s 'https://registry.hub.docker.com/v2/repositories/library/centos/tags?page_size=1024'|jq '."results"[]["name"]' 
+15
May 7 '17 at 10:08 a.m.
source share

The Docker V2 API requires an OAuth token with appropriate statements. In my opinion, the official documentation on this topic is rather vague. So that others do not experience the same pain as me, I suggest the docker-tags function below.

The latest version of docker-tags can be found in my GitHubGist: "List of Docker image tags using bash . "

The docker-tags function is dependent on jq . If you play with JSON, most likely you already have it.

 #!/usr/bin/env bash docker-tags() { arr=("$@") for item in "${arr[@]}"; do tokenUri="https://auth.docker.io/token" data=("service=registry.docker.io" "scope=repository:$item:pull") token="$(curl --silent --get --data-urlencode ${data[0]} --data-urlencode ${data[1]} $tokenUri | jq --raw-output '.token')" listUri="https://registry-1.docker.io/v2/$item/tags/list" authz="Authorization: Bearer $token" result="$(curl --silent --get -H "Accept: application/json" -H "Authorization: Bearer $token" $listUri | jq --raw-output '.')" echo $result done } 

example

 docker-tags "microsoft/nanoserver" "microsoft/dotnet" "library/mongo" "library/redis" 

Admittedly, docker-tags makes a few assumptions. In particular, OAuth request parameters are mostly hard-coded. A more ambitious implementation will create a registry request without authentication and get the OAuth parameters from the unauthenticated response.

+8
Aug 19 '18 at 21:08
source share

See the CLI utility: https://www.npmjs.com/package/docker-browse

Lets you list tags and images.

docker-browse tags <image> display all the tags for the image. e.g. docker-browse tags library/alpine

docker-browse images display all the images in the registry. Currently not available for index.docker.io .

You can connect it to any registry, including your personal one, if it supports the Docker Registry HTTP API V2

+4
Aug 30 '17 at 13:37 on
source share

Based on the answer of Yan Foto ( API v2 ), I created a simple Python script to display a list of tags for a given image .

Using:

 ./docker-registry-list.py alpine 

Exit:

 { "name": "library/alpine", "tags": [ "2.6", "2.7", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7", "edge", "latest" ] } 
+4
Mar 26 '18 at 15:26
source share

If a JSON parsing tool, jq is available

 wget -q https://registry.hub.docker.com/v1/repositories/debian/tags -O - | \ jq -r .[].name 
+3
Mar 18 '17 at 19:55
source share

You can also use this tray:

 # vim /usr/sbin/docker-tags 

& Add the following (as is):

 #!/bin/bash im="$1" [[ -z "$im" ]] && { echo -e '\e[31m[-]\e[39m Where is the image name ??' ; exit ; } [[ -z "$(echo "$im"| grep -o '/')" ]] && { link="https://hub.docker.com/r/library/$im/tags/" ; } || { link="https://hub.docker.com/r/$im/tags/" ; } resp="$(curl -sL "$link")" err="$(echo "$resp" | grep -o 'Page Not Found')" if [[ ! -z "$err" ]] ; then echo -e "\e[31m[-]\e[39m No Image Found with name => [ \e[32m$im\e[39m ]" exit else tags="$(echo "$resp"|sed -e 's|}|\n|g' -e 's|{|\n|g'|grep '"result"'|sed -e 's|,|\n|g'|cut -d '[' -f2|cut -d ']' -f1|sed '/"tags":/d'|sed -e 's|"||g')" echo -e "\e[32m$tags\e[39m" fi 

Make executable:

 # chmod 755 /usr/sbin/docker-tags 

Then finally try:

 $ docker-tags testexampleidontexist [-] No Image Found with name => [ testexampleidontexist ] $ docker search ubuntu $ docker-tags teamrock/ubuntu latest 

[I hope that before you start any command, you know $ and # ]

+2
Apr 6 '17 at 17:33
source share

Here is the Powershell script I wrote for Windows. Knobs v1 and v2 repo:

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 } 
+2
Jul 12 '18 at 18:04
source share

The Docker registry API has an endpoint for listing all tags .

It looks like Tutum has a similar endpoint , as well as a way to access through tutum-cli .

With tutum-cli, try the following:

 tutum tag list <uuid> 
+1
04 Feb '15 at 12:45
source share
 curl -u <username>:<password> https://$your_registry/v2/$image_name/tags/list -s -o - | \ tr -d '{' | tr -d '}' | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | \ awk -F: '{print $3}' | sed -e 's/,/\n/g' 

You can use it if your env does not have "jq", =)

+1
Apr 26 '17 at 4:14
source share

Get all tags from the Docker Hub: this command uses the jq command line JSON processor to select tag names from the JSON returned by the Docker Hub registry (quotes are removed using tr ). Replace the library with the Docker Hub username, debian with the image name:

 curl -s 'https://registry.hub.docker.com/v2/repositories/library/debian/tags/' | jq -r '."results"[]["name"]' 
+1
May 28 '17 at 7:54
source share

I did this when I needed to complete a task in which, if the user somehow enters the wrong tag, we must provide a list of all the tags present in the repo (Docker repo) present in the registry. So I have the code in a batch script.

 <html> <pre style="background-color:#bcbbbb;"> @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 ) </pre> </html> 

Thus, in this we can give arguments for our batch file, for example:

  Dockerfile java version7 
0
Dec 26 '18 at 11:26
source share

To view all available tags in a browser:

https://registry.hub.docker.com/v1/repositories/<username>/<image_name>/tags

those. https://hub.docker.com/r/localstack/localstack/tags

Or you can get a json response using this endpoint:

https://registry.hub.docker.com/v1/repositories/localstack/localstack/tags

0
Jun 05 '19 at 17:13
source share

Using the endpoints "/ v2 / _catalog" and "/ tags / list", you cannot get a list of all the images. If you clicked on several different images and marked them as β€œlast”, you won’t be able to list old images! You can still pull them if you refer to them using the digest "docker pull ubuntu @ sha256: ac13c5d2 ...". Thus, the answer is there is no way to list images, you can list only tags that do not match

0
Jun 13 '19 at 9:35
source share

You can achieve by running on the terminal this:

 curl -L -s 'https://registry.hub.docker.com/v2/repositories/library/mysql/tags/' | jq . | grep name 

In addition, if you do not have JQ, you must install it by

 sudo apt-get install jq 
0
Jun 28 '19 at 20:56 on
source share

This is the built-in Docker functionality:

 docker images gitlabregistry.domain.com/path/to-app 

Results in

 REPOSITORY TAG IMAGE ID CREATED SIZE gitlabregistry.domain.com/path/to-app 3.0.1 f60f49fba3e0 2 months ago 148MB ... 
-one
Mar 10 '19 at 20:42
source share



All Articles