docker imageの特定tagを確認するのが面倒
ということで、「参考」に貼ったリンク先のQiita記事で書いてある通り、ほかの人が作ったスクリプトを利用させていただきました。
#!/bin/bash ########## # 引数が1より小さいときはヘルプを表示 ########## 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 ########## # 第一引数で指定のtag(イメージ名)を検索する ########## 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}'` ########## # 第二引数で指定のtag(バージョン)が存在するかを確認 ########## if [ -n "$2" ]; then tags=` echo "${tags}" | grep "$2" ` fi echo "${tags}"
実行権限を付与して、PATHを通しておく。 実行例は以下の通り。
# ubuntu imageで、「2020」が入っているものだけをリストアップ $ dockertags.sh ubuntu 2020