泰晓科技 -- 聚焦 Linux - 追本溯源,见微知著!
网站地址:https://tinylab.org

泰晓RISC-V实验箱,不会吃灰,开箱即用
请稍侯

列出某个 Docker 镜像的所有 tags

Wu Zhangjin 创作于 2019/12/19

By Falcon of TinyLab.org Dec 09, 2019

Docker tags 非常类似 Git tags,用于标记某个历史版本(变更点)。

不过比较可惜的是,没有类似 git tag 这样的工具用于直接查看 Docker images 的历史 tags,所以,要想找到某个 image 的特定版本就不容易。

比如说,想用某个历史版本的 ubuntu 镜像,是否存在以及如何指定呢?

查找了一下,发现 docker 提供了一个接口,用法如下:

$ sudo apt-get install jq
$ curl -s https://registry.hub.docker.com/v2/repositories/library/ubuntu/tags/ | jq '."results"[]["name"]'  
"trusty"
"14.04"
"trusty-20190515"
"xenial-20191108"
"xenial"
"trusty-20191107"
"rolling"
"eoan-20191101"
"eoan"
"19.10"

这样,就可以用 docker 拉下来特定版本,例如:

$ docker pull ubuntu:14.04

类似地,可以查看其他 Docker 镜像,例如 Debian:

$ curl -s https://registry.hub.docker.com/v2/repositories/library/debian/tags/ | jq '."results"[]["name"]' 
"unstable-slim"
"unstable-20191118-slim"
"unstable-20191118"
"unstable"
"testing-slim"
"testing-backports"
"testing-20191118-slim"
"testing-20191118"
"testing"
"stretch-slim"

对于其他镜像,需要把 library/debian 整体替换为镜像名,例如:tinylab/linux-lab

$ curl -s 'https''://registry.hub.docker.com/v2/repositories/tinylab/linux-lab/tags/' | jq '."results"[]["name"]' "latest"
"20191030"
"20190909"
"backup"
"0617"
"2016"


Read Related:

Read Latest: