
我正在嘗試將 Harbor 配置為連結到 Docker hub 的拉通註冊表。
雖然我設法透過為圖像添加前綴來提取圖像根據文件,我無法透過使用 Docker 守護程序參數使其工作registry-mirrors
:諸如docker pull mysql
still 從 docker.io 下載層之類的命令。
客戶端配置
Docker版本:20.10.8
/etc/docker/daemon.log:
{
"registry-mirrors": ["https://harbor.example.com"]
}
港口配置
- 港口 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 快取中提取圖像而無需手動添加前綴?