在虚拟机上通过Docker Compose部署了一个Harbor服务,通过Nginx反向代理了Harbor服务,实现可以通过域名访问Harbor。

通过配置的外网域名进行镜像的推送,镜像推送到一半,直接出现unknown blob,通过IP直接推送到Harbor仓库则没问题。

8e5669d83291: Pushing [==================================================>]  3.584kB
9975392591f2: Pushing  2.048kB
529cdb636f61: Pushing [==================================================>]  27.75MB/27.75MB
4b8e2801e0f9: Pushing [==================================================>]  4.238MB/4.238MB
9b24afeb7c2f: Pushing [==================================================>]  338.4kB
2edcec3590a4: Waiting
unknown blob

解决方案如下,参考Issue

sudo vi common/config/registry/config.yml

在http的配置下面,新增relativeurls: true配置项:

http:
  # Add the following line
  relativeurls: true

然后重启Harbor:

sudo docker compose restart
# Or
sudo docker-compose restart

这个Issue也有说明,每次运行install.sh都会重新覆盖该文件,也就是说都得重新修改该配置。

Note: You should do this every time after you run the install.sh script, as install.sh will overwrite all files under the common directory.