4.7. 标记镜像
使用 podman tag
命令给本地镜像添加额外的名称。此额外名称可由几个部分组成:<registryhost>/<username>/<name>:<tag>。
先决条件
-
container-tools
模块已安装。 - 本地系统上提供了拉取的镜像。
流程
列出所有镜像:
$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.redhat.io/ubi8/ubi latest 3269c37eae33 7 weeks ago 208 MB
使用以下选项之一将
myubi
名称分配给registry.redhat.io/ubi8/ubi
镜像:镜像名称:
$ podman tag registry.redhat.io/ubi8/ubi myubi
镜像 ID:
$ podman tag 3269c37eae33 myubi
两个命令会给出同样的结果。
列出所有镜像:
$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.redhat.io/ubi8/ubi latest 3269c37eae33 2 months ago 208 MB localhost/myubi latest 3269c37eae33 2 months ago 208 MB
请注意,两个镜像的默认标签都是
latest
。您可以看到所有镜像名称都被分配给单个镜像 ID 3269c37eae33。使用以下方法将
8
标签添加到registry.redhat.io/ubi8/ubi
镜像:镜像名称:
$ podman tag registry.redhat.io/ubi8/ubi myubi:8
镜像 ID:
$ podman tag 3269c37eae33 myubi:8
两个命令会给出同样的结果。
列出所有镜像:
$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.redhat.io/ubi8/ubi latest 3269c37eae33 2 months ago 208 MB localhost/myubi latest 3269c37eae33 2 months ago 208 MB localhost/myubi 8 3269c37eae33 2 months ago 208 MB
请注意,两个镜像的默认标签都是
latest
。您可以看到所有镜像名称都被分配给单个镜像 ID 3269c37eae33。
标记 registry.redhat.io/ubi8/ubi
镜像后,您有三个选项来运行容器:
-
按 ID (
3269c37eae33
) -
按名称(
localhost/myubi:latest
) -
按名称(
localhost/myubi:
8)
其它资源
-
系统中的
podman-tag
手册页