• Unreal is funny !!!

Harbor 在ubuntu 18.04上的安装

Linux 站长 4年前 (2021-06-09) 1005次浏览 已收录 0个评论
文章目录[隐藏]

Harbor 是 Docker 企业级镜像仓库,今天就在我的 ubuntu 18.04 上 安装 一下,这玩意难装死了,花费了我大半天的时间。

我的安装环境

vmware 虚拟机: ubuntu sever 18.04, 内存6G
Docker版本: Docker version 20.10.2, build 20.10.2-0ubuntu1~18.04.2
docker-compose版本:docker-compose version 1.29.2, build 5becea4c
下载的harbor 离线安装包: harbor-offline-installer-v2.2.2.tgz

安装过程

解压 harbor-offline-installer-v2.2.2.tgz 并 cd进去

这里有一个配置文件 harbor.yml (如果没有就把 harbor.yml.tmpl 复制一份 ),需要编辑:

  1. # The IP address or hostname to access admin UI and registry service.
  2. # DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
  3. hostname: harbor.xiaxudong.com
  4.  
  5. # http端口号,我们用 https连接,这里就随便配吧
  6. http:
  7. # port for http, default is 80. If https enabled, this port will redirect to https port
  8. port: 9090
  9.  
  10. #https related config
  11. https:
  12. # https port for harbor, default is 443
  13. port: 443
  14. # The path of cert and key files for nginx
  15. # 这里是 https 需要的 密钥 等信息
  16. certificate:/home/ki/encrypt/privkey.pem
  17. private_key: /home/ki/encrypt/privkey.pem
  18.  

看网上说,harbor 也支持http 连接,需要在 /etc/docker/daemon.json 或者 docker.service 配置 insecure-registries ,
我试了很多遍,不行,所以还是使用https吧。
但是https 需要 ssl证书信息,我们是在虚拟机里配,不是公网,所以要 自签证书,
根据 网上 大部分的openssl 自签证书配置,均失败,
而且这里有个问题,就是即使自签证书成功,你在其他虚拟机上连接的时候也要导入自制证书,太麻烦。

ssl 解决方案:

我的博客域名是 xiaxudong.com, 我可以在 Let’s encrypt 上申请 *.xiaxudong.com的证书,然后复制到本地虚拟机,
本地虚拟机可以联网,配置 harbor.xiaxudong.com 的 hosts 后即可 https 访问本地的 harbor 。

申请证书参考:
https://qizhanming.com/blog/2019/04/23/how-to-install-let-s-encrypt-wildcards-certificate-on-centos-7
我在博客的公网机器上申请好证书,拷贝到以下目录:
/home/ki/encrypt/privkey.pem
/home/ki/encrypt/privkey.pem

然后 编辑 harbor.yml 的证书相关配置如上即可。

在每个需要访问 harbor仓库的机器上 编辑hosts:

  1. 10.2.156.97 harbor.xiaxudong.com #10.2.156.97 是 harbor 虚拟机ip

执行安装

  1. ./install.sh

在浏览器中访问 harbor.xiaxudong.com 即可。


本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Harbor 在ubuntu 18.04上的安装
喜欢 (0)
[]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址