使用 Harbor 的 `registry-mirrors` 作为拉通注册表缓存

使用 Harbor 的 `registry-mirrors` 作为拉通注册表缓存

我正在尝试将 Harbor 配置为链接到 Docker hub 的直通注册表。

虽然我设法通过添加前缀来提取图像根据文档,我无法使用 Docker 守护程序参数使其工作registry-mirrors:诸如docker pull mysql仍然从 docker.io 下载层的命令。

客户端配置

Docker 版本:20.10.8

/etc/docker/daemon.log:

{
  "registry-mirrors": ["https://harbor.example.com"]
}

Harbor 配置

  • 海港 v2.3.1
  • 使用安装docker-compose
  • 在 Harbor 界面中:
    • 注册表\新端点:以“Docker Hub”作为提供者创建端点。
    • 项目 \ 新项目:将名称设置为proxy,勾选“代理缓存”并选择上述端点。

测试 1:拉取带前缀的镜像:

$ docker pull harbor.example.com/proxy/library/mysql
Using default tag: latest
latest: Pulling from proxy/library/mysql
33847f680f63: Already exists 
5cb67864e624: Already exists 
1a2b594783f5: Already exists 
b30e406dd925: Already exists 
48901e306e4c: Already exists 
603d2b7147fd: Already exists 
802aa684c1c4: Already exists 
715d3c143a06: Pull complete 
6978e1b7a511: Pull complete 
f0d78b0ac1be: Pull complete 
35a94d251ed1: Pull complete 
36f75719b1a9: Pull complete 
Digest: sha256:8b928a5117cf5c2238c7a09cd28c2e801ac98f91c3f8203a8938ae51f14700fd
Status: Downloaded newer image for harbor.example.com/proxy/library/mysql:latest
harbor.example.com/proxy/library/mysql:latest

倒数第二行显示这是按预期从我的仓库中提取的。

测试2:拉取无前缀的镜像:

$ docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
33847f680f63: Already exists 
5cb67864e624: Already exists 
1a2b594783f5: Already exists 
b30e406dd925: Already exists 
48901e306e4c: Already exists 
603d2b7147fd: Already exists 
802aa684c1c4: Already exists 
715d3c143a06: Pull complete 
6978e1b7a511: Pull complete 
f0d78b0ac1be: Pull complete 
35a94d251ed1: Pull complete 
36f75719b1a9: Pull complete 
Digest: sha256:8b928a5117cf5c2238c7a09cd28c2e801ac98f91c3f8203a8938ae51f14700fd
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest

这是来自 docker.io 而不是从我的注册表中获取的!执行上述命令后,我还在 /var/log/syslog 中看到此行:

Aug 11 15:54:57 myhost dockerd[12663]: time="2021-08-11T15:54:57.229516951+02:00" level=info msg="Attempting next endpoint for pull after error: unknown: repository library/mysql not found"

由于这表明 Docker 首先尝试了我的注册表,因此我怀疑问题出在注册表的配置中,而不是 Docker 中。也许是在 Harbor 使用的路径约定中……

有人能够从 Harbor 缓存中提取图像而无需手动添加前缀吗?

相关内容