How to list the tag of a container image

by Daniel Pham
Published: Updated:
This entry is part 4 of 4 in the series Instructions for installing and using the Docker

How to list the tag of a container image? In the previous article, you already know what the tag of an image container is.

On the Docker Hub website, you can see all the tags easily.

But if you use the search command, how can you list all tags of an image?

Docker registry API

If you remember, the search command in docker does not display the image tag. So what will we do?

Docker supports something called Docker registry API, you can use these APIs to get the information you need.

The idea is that you will use the API to get information about the tag of a certain image.

What is MJSON?

A little more you will understand why we use MJson. So, what is it?

Mjson is a tool that helps us print json results in “better” form. In general, its purpose is to make it easier to see results.

The command list all tags of an image

command to list all tag of an image
Command to list all tags of an image.

The following command will help you list all tags of an image.


The syntax of the command is very simple, you just need to change the name of the image before the tag section.

For example, I use the search command to list all image centos.

root@linux:~# docker search centos
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
centos                             The official build of CentOS.                   5325                [OK]                
ansible/centos7-ansible            Ansible on Centos7                              121                                     [OK]
jdeathe/centos-ssh                 CentOS-6 6.10 x86_64 / CentOS-7 7.5.1804 x86…   107                                     [OK]
consol/centos-xfce-vnc             Centos container with "headless" VNC session…   86                                      [OK]
imagine10255/centos6-lnmp-php56    centos6-lnmp-php56                              54                                      [OK]
centos/mysql-57-centos7            MySQL 5.7 SQL database server                   51                                      
tutum/centos                       Simple CentOS docker image with SSH access      44                                      
openshift/base-centos7             A Centos7 derived base image for Source-To-I…   43                                      
gluster/gluster-centos             Official GlusterFS Image [ CentOS-7 +  Glust…   41                                      [OK]
centos/postgresql-96-centos7       PostgreSQL is an advanced Object-Relational    37                                      
centos/python-35-centos7           Platform for building and running Python 3.5   35                                      
kinogmt/centos-ssh                 CentOS with SSH                                 26                                      [OK]
openshift/jenkins-2-centos7        A Centos7 based Jenkins v2.x image for use w…   20                                      
centos/php-56-centos7              Platform for building and running PHP 5.6 ap…   20                                      
pivotaldata/centos-gpdb-dev        CentOS image for GPDB development. Tag names…   10                                      
openshift/wildfly-101-centos7      A Centos7 based WildFly v10.1 image for use    6                                       
openshift/jenkins-1-centos7        DEPRECATED: A Centos7 based Jenkins v1.x ima…   4                                       
pivotaldata/centos                 Base centos, freshened up a little with a Do…   3                                       
darksheer/centos                   Base Centos Image -- Updated hourly             3                                       [OK]
pivotaldata/centos-mingw           Using the mingw toolchain to cross-compile t…   2                                       
blacklabelops/centos               CentOS Base Image! Built and Updates Daily!     1                                       [OK]
pivotaldata/centos-gcc-toolchain   CentOS with a toolchain, but unaffiliated wi…   1                                       
openshift/wildfly-81-centos7       A Centos7 based WildFly v8.1 image for use w…   1                                       
smartentry/centos                  centos with smartentry                          0                                       [OK]
pivotaldata/gpdb6-centos6-build    CentosOS 6 image for GPDB 6 compilation         0                                       

And now I want to know the tags of the image named ansible/centos7-ansible.

We will make 2 examples with mjson and no mjson.

Without mjson.

root@linux:~# curl
[{"layer": "", "name": "latest"}, {"layer": "", "name": "1.7"}, {"layer": "", "name": "1.8"}, {"layer": "", "name": "devel"}, {"layer": "", "name": "master"}, {"layer": "", "name": "stable"}]

And with mjson.

root@linux:~# curl | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   191    0   191    0     0    185      0 --:--:--  0:00:01 --:--:--   185
        "layer": "",
        "name": "latest"
        "layer": "",
        "name": "1.7"
        "layer": "",
        "name": "1.8"
        "layer": "",
        "name": "devel"
        "layer": "",
        "name": "master"
        "layer": "",
        "name": "stable"

You see the results are different. With mjson, we have a better looking result.


This is just a simple trick, it does not require you to have a deep understanding of docker. But it is a very useful thing because you don’t always have a browser to use. You work with the command line server and you must use the command. Right?

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating
Series Navigation«« Previous part: How to search for a container image

You may also like

Notify of
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.



Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 – All rights reserved.

Please write sources “” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Would love your thoughts, please comment.x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.