LoginSignup
15
8

More than 3 years have passed since last update.

DockerHub Dockerイメージのタグ一覧を取得するコマンドを作る

Last updated at Posted at 2020-03-14

Dockerイメージの検索は docker search コマンドが用意されているがイメージのタグ情報は検索できないようです...(困惑)

タグを取得するAPIは提供されていたのでそれを使ってDockerイメージのタグ一覧を取得します。

環境

  • Mac

Dockerイメージの検索

$ docker search ubuntu
NAME                                                      DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
ubuntu                                                    Ubuntu is a Debian-based Linux operating sys…   10614               [OK]
dorowu/ubuntu-desktop-lxde-vnc                            Docker image to provide HTML5 VNC interface …   404                                     [OK]
rastasheep/ubuntu-sshd                                    Dockerized SSH service, built on top of offi…   243                                     [OK]
consol/ubuntu-xfce-vnc                                    Ubuntu container with "headless" VNC session…   211                                     [OK]
ubuntu-upstart                                            Upstart is an event-based replacement for th…   106                 [OK]

...

前提条件

  • curl, jq コマンドが必要です。
$ brew install jq

イメージのタグを取得する

ubuntu イメージのタグは下記のAPIから取得できます。

イメージ名のところを引数にしてコマンドを作れば良さそうです。

.bash_profile
function docker-tags {
  curl -s https://registry.hub.docker.com/v1/repositories/$1/tags | jq -r '.[].name'
}

自作した docker-tags コマンドを実行してみる。

$ docker-tags ubuntu
latest
10.04
12.04
12.04.5
12.10
13.04
13.10
14.04
14.04.1
14.04.2
14.04.3
14.04.4
14.04.5

...

良い感じです☺️

15
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
8