4.8. 标记镜像


使用 podman tag 命令给本地镜像添加额外的名称。此额外名称可由几个部分组成:<registryhost>/<username>/<name>:<tag>

先决条件

  • container-tools 元数据包已安装。
  • 本地系统上提供了拉取的镜像。

流程

  1. 列出所有镜像:

    $ podman images
    REPOSITORY                           TAG     IMAGE ID      CREATED      SIZE
    registry.redhat.io/ubi10/ubi          latest  3269c37eae33  7 weeks ago  208 MB
    Copy to Clipboard Toggle word wrap
  2. 使用以下选项之一将 myubi 名称分配给 registry.redhat.io/ubi10/ubi 镜像:

    • 镜像名称:

      $ podman tag registry.redhat.io/ubi10/ubi myubi
      Copy to Clipboard Toggle word wrap
    • 镜像 ID:

      $ podman tag 3269c37eae33 myubi
      Copy to Clipboard Toggle word wrap

      两个命令会给出同样的结果。

  3. 列出所有镜像:

    $ podman images
    REPOSITORY                           TAG     IMAGE ID      CREATED       SIZE
    registry.redhat.io/ubi10/ubi          latest  3269c37eae33  2 months ago  208 MB
    localhost/myubi                      latest  3269c37eae33  2 months ago  208 MB
    Copy to Clipboard Toggle word wrap

    请注意,两个镜像的默认标签都是 latest。您可以看到所有镜像名称都被分配给单个镜像 ID 3269c37eae33。

  4. 使用以下方法将 10 标签添加到 registry.redhat.io/ubi10/ubi 镜像:

    • 镜像名称:

      $ podman tag registry.redhat.io/ubi10/ubi myubi:10
      Copy to Clipboard Toggle word wrap
    • 镜像 ID:

      $ podman tag 3269c37eae33 myubi:10
      Copy to Clipboard Toggle word wrap

      两个命令会给出同样的结果。

验证

  • 列出所有镜像:

    $ podman images
    REPOSITORY                           TAG     IMAGE ID      CREATED       SIZE
    registry.redhat.io/ubi10/ubi          latest  3269c37eae33  2 months ago  208 MB
    localhost/myubi                      latest  3269c37eae33  2 months ago  208 MB
    localhost/myubi                      10     3269c37eae33  2 months ago  208 MB
    Copy to Clipboard Toggle word wrap

    请注意,两个镜像的默认标签都是 latest。您可以看到所有镜像名称都被分配给单个镜像 ID 3269c37eae33。

在标记完 registry.redhat.io/ubi10/ubi 镜像后,您有三个选项来运行容器:

  • 按 ID (3269c37eae33)
  • 按名称(localhost/myubi:latest)
  • 按名称(localhost/myubi:10)
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat