IBM Cloud Docs
为什么我在 Container Registry中收到清单列表无效错误?

为什么我在 Container Registry中收到清单列表无效错误?

在 IBM Cloud® Container Registry中尝试标记清单列表或 OCI 映像索引时,发生清单列表无效错误。CRI0304E The manifest list or OCI index that you are tagging references an image that doesn't exist

尝试在 IBM Cloud Container Registry中 标记 您的 清单 列表或 OCI 映像索引时发生以下清单列表无效错误: CRI0304E The manifest list or OCI index that you are tagging references an image that doesn't exist, see https://cloud.ibm.com/docs/Registry?topic=Registry-troubleshoot-manifest-list-error

清单列表和 OCI 映像索引包含对不同映像的引用列表,其中每个映像都适用于不同的体系结构。 标记清单列表或 OCI 映像索引时,Container Registry 会尝试复制引用的映像。 当您收到此错误消息时,它指示在注册表中找不到其中一个引用的映像。

要了解如何解决这个问题,您必须运行以下命令(其中 SOURCE_IMAGE 是源图像名称),找出清单列表或 OCI 图像索引中引用了哪些图像:

ibmcloud cr manifest-inspect SOURCE_IMAGE

其输出与此输出类似:

{
    "schemaVersion": 2,
    "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
    "manifests": [
        {
            "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
            "size": 528,
            "digest": "sha256:865b0c35e6da393b8e80b7e3799f777572399a4cff047eb02a81fa6e7a48ed4b",
            "platform": {
                "architecture": "amd64",
                "os": "linux"
            }
        },
        {
            "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
            "size": 538,
            "digest": "sha256:1d71e323557502cc78ee6c237331a09b0c33ba59c14e5f683da3b1c6218779cc",
            "platform": {
                "architecture": "ppc64le",
                "os": "linux"
            }
        }
    ]
}

要使此输出有效,具有来自先前输出的 摘要 的映像必须与您尝试标记的清单列表或 OCI 索引存在于同一存储库中。 要确认是否缺少其中一个映像,可以运行以下命令。 将 SRC_REPO 替换为名称空间和存储库的名称,格式为 mynamespace/myrepo

ibmcloud cr digests --restrict SRC_REPO

例如,运行以下命令

ibmcloud cr  digests --restrict mynamespace/myrepo

您将得到以下响应:

Listing images...

Repository                  Digest                                                                    Tags   Type                                 Created       Size     Security status
icr.io/mynamespace/myrepo   sha256:865b0c35e6da393b8e80b7e3799f777572399a4cff047eb02a81fa6e7a48ed4b   -      Docker Image Manifest V2, Schema 2   4 days ago    1.8 MB   -
icr.io/mynamespace/myrepo   sha256:a08e18417cec86f570be496b8bde1350dd986fc354d091b44d6a536570c26193   list   Docker Manifest List                 -             433 B    -

OK

在先前的示例中,您可以看到只有一个映像与清单列表 sha256:865b0c35e6da393b8e80b7e3799f777572399a4cff047eb02a81fa6e7a48ed4b 位于同一存储库中,因此清单列表正在引用存储库中当前不存在的另一个映像 sha256:1d71e323557502cc78ee6c237331a09b0c33ba59c14e5f683da3b1c6218779cc

您可以使用下列其中一个选项来解决此问题,请遵循上一个示例。

  • 如果注册表中的其他位置存在缺少的映像,那么可以使用 ibmcloud cr image-tag 命令将该映像移至同一存储库。

    1. 要检测注册表中其他位置是否存在缺少的摘要,请运行以下命令。

      ibmcloud cr digests --format '{{if eq .Digest "sha256:1d71e323557502cc78ee6c237331a09b0c33ba59c14e5f683da3b1c6218779cc"}}{{.Repository}}@{{.Digest}}{{end}}'
      icr.io/myrepo2/image2@sha256:1d71e323557502cc78ee6c237331a09b0c33ba59c14e5f683da3b1c6218779cc
      
    2. 如果先前命令返回映像,那么可以将其复制到与清单列表相同的存储库。

      ibmcloud cr image-tag icr.io/mynamespace/myrepo2@sha256:1d71e323557502cc78ee6c237331a09b0c33ba59c14e5f683da3b1c6218779cc icr.io/mynamespace/myrepo:ppc64le
      
  • 如果在过去 30 天内删除了缺少的映像,那么可以从废纸篓复原该映像。

    1. 通过运行以下命令来检测该映像是否存在于废纸篓中。

      ibmcloud cr trash-list --restrict mynamespace
      

      您将收到以下回复:

      Listing the contents of the trash...
      
      Digest                                                                                              Days until expiry   Tags
      icr.io/mynamespace/myrepo@sha256:1d71e323557502cc78ee6c237331a09b0c33ba59c14e5f683da3b1c6218779cc   30                  ppc64le
      
      
      OK
      
    2. 如果该映像确实存在于废纸篓中,那么可以通过运行以下命令来复原该映像。

      ibmcloud cr image-restore icr.io/mynamespacemyrepo@sha256:1d71e323557502cc78ee6c237331a09b0c33ba59c14e5f683da3b1c6218779cc
      

      您将收到以下回复:

      Restoring digest 'icr.io/mynamespace/myrepo@sha256:1d71e323557502cc78ee6c237331a09b0c33ba59c14e5f683da3b1c6218779cc' ...
      
      Successfully restored digest 'icr.io/mynamespace/myrepo@sha256:1d71e323557502cc78ee6c237331a09b0c33ba59c14e5f683da3b1c6218779cc'
      Successfully restored tags: ppc64le
      
      OK
      
  • 如果您具有映像的本地副本,那么可以将其推送回注册表。 有关更多信息,请参阅 将 Docker 映像推送到名称空间