检索Docker镜像的名称、标签和详细信息的方法:

简而言之

当您在没有使用别人准备好的DockerFile或docker-compose.yml的情况下进行环境设置时,您需要查找docker镜像和标签。在这里,我们将介绍如何进行这样的查询。

使用Docker Hub进行搜索。

在Docker Hub上搜索Docker镜像,请在左上角的搜索框中键入关键词进行搜索。

docker1.png

我們這次來看看最上面的一個Ubuntu映像。

docker2.png

当您选择TAG选项卡时,会显示此图像的标签列表以及每个标签的详细信息。

docker3.png

通过命令在Docker中搜索镜像。

您可以在Docker Hub上搜索镜像名,也可以使用命令进行搜索。可以使用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

用命令展示Docker镜像的标签列表

因为这个是标准命令无法执行。
我已经创建了一个shell脚本,所以我们可以用它。
让我们尝试在”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
  ・
  ・
  ・

用命令显示Docker镜像的标签列表(还显示CPU架构)

如果您使用M1Mac等设备,那么您还需要关注它们所支持的架构。
为了能够以“标签名称:架构名称”的形式输出,我们将修改上述使用的脚本(也是同一篇文章中所使用的)。
举个例子,我们来搜索一下”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
      ・
      ・
      ・

使用命令查看Docker镜像的详细信息。

如果有本地图像,你可以使用docker inspect命令查看详细信息。

$ docker inspect イメージ名:タグ名
$ docker inspect ubuntu:latest
[
    {
        "Id": "sha256:2dc39ba059dcd42ade30aae30147b5692777ba9ff0779a62ad93a74de02e3e1f",
        "RepoTags": [
            "ubuntu:latest"
        ],
        "RepoDigests": [
            "ubuntu@sha256:20fa2d7bb4de7723f542be5923b06c4d704370f0390e4ae9e1c833c8785644c1"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2022-09-01T23:46:35.375057619Z",
        "Container": "b0df58d0a952d2cb3b35163ac557fe1886c0fe5cf73a82a16491a22089aadb8c",
        "ContainerConfig": {
            "Hostname": "b0df58d0a952",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"bash\"]"
            ],
            "Image": "sha256:1f88c721b49061df8bcee6398193b3642df4f089f9343e138302473c3d58fc06",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "20.10.12",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "bash"
            ],
            "Image": "sha256:1f88c721b49061df8bcee6398193b3642df4f089f9343e138302473c3d58fc06",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 77834333,
        "VirtualSize": 77834333,
        "GraphDriver": {
            "Data": {
                "MergedDir": "/var/lib/docker/overlay2/fbb30e639893aa6f1b61507455676c945027b7beeb587f68e12d1c784bac36ad/merged",
                "UpperDir": "/var/lib/docker/overlay2/fbb30e639893aa6f1b61507455676c945027b7beeb587f68e12d1c784bac36ad/diff",
                "WorkDir": "/var/lib/docker/overlay2/fbb30e639893aa6f1b61507455676c945027b7beeb587f68e12d1c784bac36ad/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:7f5cbd8cc787c8d628630756bcc7240e6c96b876c2882e6fc980a8b60cdfa274"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

如果本地没有存在镜像,则使用docker pull将镜像下载至本地,之后使用docker inspect查看详细信息。

# イメージをローカルにダウンロード
$ docker pull ubuntu:latest
# 詳細を表示
$ docker inspect ubuntu:latest
广告
将在 10 秒后关闭
bannerAds