0

If I run this:

$ docker search node

I get some results in the terminal:

NAME                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
node                                   Node.js is a JavaScript-based platform for s…   5716                [OK]                
mhart/alpine-node                      Minimal Node.js built on Alpine Linux           363                                     
mongo-express                          Web-based MongoDB admin interface, written w…   261                 [OK]                
nodered/node-red-docker                Node-RED Docker images.                         157                                     [OK]
iojs                                   io.js is an npm compatible platform original…   126                 [OK]                
prom/node-exporter                                                                     77                                      [OK]

my question is - is there a command I can use to find all the variants of the first result?

I am looking to get a list of all the images/tags like so:

[
   "node:4.2",
   "node:5.1",
   "node:5.3",
   "node:5.45",
   "node:5.7",
   "node:6.2",
   "node:7",
   "node:8",
   "node:9",
   // ...
   "node:10"
]
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817

1 Answers1

1

Docker search doesn't have this feature

What you can do instead is use a simple curl command combine with jq :

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

Example :

curl https://registry.hub.docker.com/v1/repositories/node/tags | jq -r '.[].name'

Will return all the tags :

...
chakracore-8.11
chakracore-8.11.1
chakracore-8.9
chakracore-8.9.4
jessie
onbuild
slim
stretch
wheezy

And If you want to get all tags of all result :

for i in $(docker search --format {{.Name}} node); do
    echo "All tag for image : $i"
    curl https://registry.hub.docker.com/v1/repositories/$i/tags | jq -r '.[].name'
done

Or all tag of the first result :

name=$(docker search --limit 1 --format {{.Name}} node)
curl https://registry.hub.docker.com/v1/repositories/$name/tags | jq -r '.[].name'
callmemath
  • 8,185
  • 4
  • 37
  • 50
  • You need to authenticate https://docs.docker.com/registry/spec/api/ More example here > https://github.com/docker/distribution/issues/1968#issuecomment-248452211 – callmemath Jun 20 '18 at 23:04