概述
泊坞窗图像标签是码头工人可以从
一个页面上显示的标签并不多,而且要多次浏览页面来查找它们有点乏味。
之前 dockerhub 的 APIhttps://registry.hub.docker.com/v1/repositories/イメージ名/tags
点击 获取标签列表非常方便。
但它似乎在不久前停止工作。
码头工人当我使用开发者工具访问和调查时,现在https://hub.docker.com/v2/repositories/library/イメージ名/tags
看来你可以从
我用它来创建一个 shell 脚本来获取 docker 图像的标签列表。
外壳脚本代码
码头工人标签
#!/bin/sh
# 2022/09/18
# 問い合わせ回数を取得
num=$(echo $@ | tr ' ' '\n' | grep '\-n' | tr -d '\-n')
# ページ番号を取得
page=$(echo $@ | tr ' ' '\n' | grep '\-page' | tr -d '\-page')
# 指定されたページ番号に問い合わせ
if [ -n "${page}" ]; then
curl -s "https://hub.docker.com/v2/repositories/library/${1}/tags/?page_size=100&page=${page}" |
sed -e 's/,/\n/g' |
grep '\"name\":' |
sed -e 's/:/ /g' -e 's/\"//g' |
awk '{print $2}'
# 処理終了
exit 0
fi
# 問い合わせ回数が指定されていなければデフォルトで1とする
if [ -z "${num}" ]; then
num=1
fi
# 1ページ目から指定された回数のページまでを表示
seq ${num} | while read -r line; do
curl -s "https://hub.docker.com/v2/repositories/library/${1}/tags/?page_size=100&page=${line}" |
sed -e 's/,/\n/g' |
grep '\"name\":' |
sed -e 's/:/ /g' -e 's/\"//g' |
awk '{print $2}'
done
安装方式
1)放置在PATH通过的目录下,或者通过放置目录的PATH
例子)
・~/binというディレクトリを作成し、本スクリプトを配置
・~/binのPATHを通す
2) 授予执行权限
$ chmod +x docker-tags
如何使用
- 没有选项
$ docker-tags イメージ名
# 1ページ分表示される
- 指定要显示的页数
$ docker-tags イメージ名 -n10
# 10ページ分表示される
- 要显示的页面数字指定
$ docker-tags イメージ名 -page10
# 10ページ目のみ表示される
使用示例
例如,搜索“ubuntu”。
例子)
$ docker-tags ubuntu
latest
bionic-20220902
bionic
18.04
rolling
kinetic-20220830
kinetic
jammy-20220815
jammy
focal-20220826
focal
devel
bionic-20220829
22.10
22.04
20.04
・
・
・
奖励 1:图像名称搜索
图片名称搜索码头工人您可以使用 执行此操作,但您也可以使用命令执行此操作。
使用docker search。
格式
$ docker search キーワード
例如,搜索“ubuntu”。
带有斜线“/”,斜线后的图像名称是。
例子)
$ docker search ubuntu
ubuntu Ubuntu is a Debian-based Linux operating sys… 14955 [OK]
websphere-liberty WebSphere Liberty multi-architecture images … 288 [OK]
ubuntu-upstart DEPRECATED, as is Upstart (find other proces… 112 [OK]
neurodebian NeuroDebian provides neuroscience research s… 93 [OK]
ubuntu/nginx Nginx, a high-performance reverse proxy & we… 59
open-liberty Open Liberty multi-architecture images based… 54 [OK]
ubuntu-debootstrap DEPRECATED; use "ubuntu" instead 46 [OK]
ubuntu/apache2 Apache, a secure & extensible open-source HT… 41
ubuntu/mysql MySQL open source fast, stable, multi-thread… 36
ubuntu/squid Squid is a caching proxy for the Web. Long-t… 32
kasmweb/ubuntu-bionic-desktop Ubuntu productivity desktop for Kasm Workspa… 31
ubuntu/prometheus Prometheus is a systems and service monitori… 29
ubuntu/bind9 BIND 9 is a very flexible, full-featured DNS… 27
ubuntu/postgres PostgreSQL is an open source object-relation… 19
ubuntu/redis Redis, an open source key-value store. Long-… 11
ubuntu/kafka Apache Kafka, a distributed event streaming … 11
ubuntu/prometheus-alertmanager Alertmanager handles client alerts from Prom… 7
ubuntu/grafana Grafana, a feature rich metrics dashboard & … 6
ubuntu/memcached Memcached, in-memory keyvalue store for smal… 5
ubuntu/zookeeper ZooKeeper maintains configuration informatio… 5
ubuntu/telegraf Telegraf collects, processes, aggregates & w… 4
ubuntu/dotnet-deps Chiselled Ubuntu for self-contained .NET & A… 3
ubuntu/cortex Cortex provides storage for Prometheus. Long… 3
ubuntu/cassandra Cassandra, an open source NoSQL distributed … 2
ubuntu/loki Grafana Loki, a log aggregation system like … 0
奖励 2:一起显示支持的架构
特别是如果你使用的是 M1Mac 等,你必须担心支持的架构。
下面的代码是将上述脚本修改为以タグ名:アーキテクチャ名 格式输出。
*我只写它应该工作的想法。 . .搬家就好了. .
我想知道如果我使用 jq 命令是否可以写得更聪明。 . .
docker-tags_arch
#!/bin/sh
# 2022/09/18
# 問い合わせ回数を取得
num=$(echo $@ | tr ' ' '\n' | grep '\-n' | tr -d '\-n')
# ページ番号を取得
page=$(echo $@ | tr ' ' '\n' | grep '\-page' | tr -d '\-page')
# 指定されたページ番号に問い合わせ
if [ -n "${page}" ]; then
curl -s "https://hub.docker.com/v2/repositories/library/${1}/tags/?page_size=100&page=${page}" |
sed -e 's/,/\n/g' |
grep -E 'architecture|\"name\":' |
tac |
tr -d '\n' |
sed -e 's/\"images\"//g' -e 's/\"name\":/\n/g' -e 's/{\"architecture\"//g' -e 's/\"//g' -e 's/\[://g' -e 's/:/ /g' |
awk '{print $1":"$2,$3,$4,$5,$6,$7,$8,$9,$10}' |
tac |
sed -e 's/ *$//g' -e 's/ /, /g' -e 's/^:$//'
# 処理終了
exit 0
fi
# 問い合わせ回数が指定されていなければデフォルトで5とする
if [ -z "${num}" ]; then
num=1
fi
# 1ページ目から指定された回数のページまでを表示
seq ${num} | while read -r line; do
curl -s "https://hub.docker.com/v2/repositories/library/${1}/tags/?page_size=100&page=${line}" |
sed -e 's/,/\n/g' |
grep -E 'architecture|\"name\":' |
tac |
tr -d '\n' |
sed -e 's/\"images\"//g' -e 's/\"name\":/\n/g' -e 's/{\"architecture\"//g' -e 's/\"//g' -e 's/\[://g' -e 's/:/ /g' |
awk '{print $1":"$2,$3,$4,$5,$6,$7,$8,$9,$10}' |
tac |
sed -e 's/ *$//g' -e 's/ /, /g' -e 's/^:$//' |
grep -vE '^$'
done
例如,搜索“ubuntu”。
例子)
$ docker-tags_arch ubuntu
latest:s390x, riscv64, ppc64le, arm64, arm, amd64
bionic-20220902:s390x, ppc64le, 386, arm64, arm, amd64
bionic:s390x, ppc64le, 386, arm64, arm, amd64
18.04:s390x, ppc64le, 386, arm64, arm, amd64
rolling:s390x, riscv64, ppc64le, arm64, arm, amd64
kinetic-20220830:s390x, riscv64, ppc64le, arm64, arm, amd64
kinetic:s390x, riscv64, ppc64le, arm64, arm, amd64
jammy-20220815:s390x, riscv64, ppc64le, arm64, arm, amd64
jammy:s390x, riscv64, ppc64le, arm64, arm, amd64
focal-20220826:s390x, riscv64, ppc64le, arm64, arm, amd64
focal:s390x, riscv64, ppc64le, arm64, arm, amd64
devel:s390x, riscv64, ppc64le, arm64, arm, amd64
bionic-20220829:s390x, ppc64le, 386, arm64, arm, amd64
22.10:s390x, riscv64, ppc64le, arm64, arm, amd64
22.04:s390x, riscv64, ppc64le, arm64, arm, amd64
20.04:s390x, riscv64, ppc64le, arm64, arm, amd64
・
・
・
原创声明:本文系作者授权爱码网发表,未经许可,不得转载;
原文地址:https://www.likecs.com/show-308626163.html