HOW TO LIST ALL TAGS OF A DOCKER IMAGE


DOCKER SEARCH
To search a image on docker remote registry you can use docker search command.
Example:
root@googlinux.com:~# docker search ubuntu
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating s... 4482 [OK]
ubuntu-upstart Upstart is an event-based replacement for ... 65 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 32 [OK]
torusware/speedus-ubuntu Always updated official Ubuntu docker imag... 27 [OK]
This example displays images with a name containing ubuntu
. First column displays the name of image. You may notice rastasheep/ubuntu-sshd
has a /
in the name. The left portion i.e. rastasheep
is the username and right portion i.e. ubuntu-sshd
is the image name. Some image does not have a /
in the name, just like the first one i.e. ubuntu
. In this case library
is the username
Note: Search queries will only return up to 25 results. You can use --limit option to change the search result display limit.
DOCKER PULL
docker pull
is the command to pull docker image from remote registry.
root@googlinux.com:~# docker pull debian
Using default tag: latest
latest: Pulling from library/debian
This will try to pull the image with latest tag.
LIST FIRST 10 TAGS
Listing all the available tag can be tricky. Well that information is always available on the image info page on hub.docker.com. There are lot of cases that you may need this information using a command line. This can be done using a simple API call and parsing the json
output using jq
tool.
root@googlinux.com:~# curl 'https://registry.hub.docker.com/v2/repositories/library/debian/tags/'|jq '."results"[]["name"]'
"7.11"
"testing"
"oldstable-backports"
"oldstable"
"8"
"8.5"
"stretch"
"experimental"
"rc-buggy"
"wheezy-backports"
Note:jq
is a tool for processing JSON inputs.jq
is likesed
for JSON data - you can use it to slice and filter and map and transform structured data with the same ease thatsed
,awk
,grep
and friends let you play with text.
A SCRIPT TO LIST ALL TAGS
i=0
while [ $? == 0 ]
do
i=$((i+1))
curl https://registry.hub.docker.com/v2/repositories/library/debian/tags/?page=$i 2>/dev/null|jq '."results"[]["name"]'
done
and now debian image with a specific tag can be pulled using
root@googlinux.com:~# docker pull debian:testing
Or if you want to pull all tag of a image
root@googlinux.com:~# docker pull -a debian
Like it? Click here to Tweet your feedback