从具有两个存储库的私有 docker 注册表拉取时出现意外的 EOF

问题描述 投票:0回答:1

设置

  • 我使用 docker 的官方注册表(作为 docker 容器)托管一个私有 docker 注册表 (https://hub.docker.com/%5C_/registry)。

  • 在该注册表中,我有两个存储库

    repo1
    repo2

  • 它们可以被视为一个应用程序的不同风格,因此共享一些层

  • 我正在将图像从单独的构建服务器推送到该注册表

  • 我知道相关问题(Docker pull 失败并出现意外的 EOF),但他们既没有提供根本原因的解决方案,也没有可靠的解决方法解决我的问题

问题

  • 从该注册表中提取时,我(有时)得到:
docker pull registry.foobar.com/repo1/repo1:latest 
latest: Pulling from repo1/repo1
125a6e411906: Already exists 
ab029ed1e0ab: Already exists 
bd96b0d396b3: Pull complete 
e0135e3ddcf1: Pull complete 
6a8cac0382d1: Pull complete 
756f32f3ded1: Downloading [==================================================>]  2.291kB/2.291kB
unexpected EOF 
  • 其他存储库上也存在同样的问题:
docker pull registry.foobar.com/repo2/repo2:latest 
latest: Pulling from repo2/repo2
<different SHA>: Already exists 
<different SHA>: Already exists 
<different SHA>: Pull complete 
<different SHA>: Pull complete 
<different SHA>: Pull complete 
756f32f3ded1: Downloading # <<< same sha as the other repo [==================================================>]  2.291kB/2.291kB
unexpected EOF 

调查(到目前为止):

  • 登录注册表并检查文件系统级别时,我发现注册表中甚至不存在故障层(因此

    EOF
    100%有意义...)

  • 我通过首先从清单中检索完整的 sha256 然后执行来删除相应的层:

curl --user "$USER:$PASS" -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' -k -X DELETE "https://registry.com/v2/repo1/repo1/blobs/sha256:THE_SHA"
  • 删除图层并重新推送后我可以看到:

    docker push registry.foobar.com/repo1/repo1:latest
    The push refers to repository [registry.foobar.com/repo1/repo1]
    c9a6d53cb9c5: Mounted from repo2/repo2 # <<<<< this caught my attention!
    231dc2de5585: Layer already exists 
    4c868cb538dc: Layer already exists 
    7a3259a58e8b: Layer already exists 
    a4ed6cf37dad: Layer already exists 
    256d88da4185: Layer already exists 
    latest: digest: sha256:904655eda0e83255442c57011f1b0cb37d045612925d1893fa530136f234104c size: 1583
    
  • 但是重新推送并不能解决拉取过程中的问题

我以某种方式期待两个存储库之间的共享层,并且受影响的层甚至不会传输到注册表。但到目前为止我还没有真正的证据,也没有解决这个问题的方法。

我可以毫无问题地进行 docker pull。

docker docker-registry
1个回答
0
投票

您的注册表已损坏,您需要通过从注册表状态中删除 Blob 存储中不存在的 Blob 来纠正该损坏。这是通过检查图像以获取失败 Blob 的完整 Blob 摘要来完成的:

docker buildx imagetools inspect $image

然后使用注册表 API 从它们可能所在的每个存储库中删除这些 blob:

curl --user "$USER:$PASS" -k -X DELETE "https://${registry}/v2/${repo}/blobs/sha256:${digest}"
© www.soinside.com 2019 - 2024. All rights reserved.