根据 Harbor 官方描述:
Harbor 是一个用于存储和分发 Docker 镜像的企业级 Registry 服务器, 通过添加一些企业必需的功能特性, 例如安全, 标识和管理等, 扩展了开源 Docker Distribution. 作为一个企业级私有 Registry 服务器, Harbor 提供了更好的性能和安全. 提升用户使用 Registry 构建和运行环境传输镜像的效率. Harbor 支持安装在多个 Registry 节点的镜像资源复制, 镜像全部保存在私有 Registry 中, 确保数据和知识产权在公司内部网络中管控. 另外, Harbor 也提供了高级的安全特性, 诸如用户管理, 访问控制和活动审计等.
注: 1.8 之前的版本用起来比较麻烦, 还要生成 https 证书, 1.8 直接拿过来就用, 而且低版本的启动时候有几个容器一直在显示重启中, 就先写一个高版本的安装
安装前提:
前面的文章说过, 要替换高版本的 docker, 这里就展示一下版本信息
- [[email protected] tmp]# docker --version
- Docker version 19.03.4, build 9013bf583a
- [root@topcheer tmp]#
也要安装 docker-compose
- [[email protected] ~]# curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
- % Total % Received % Xferd Average Speed Time Time Time Current
- Dload Upload Total Spent Left Speed
- 100 617 0 617 0 0 382 0 --:--:-- 0:00:01 --:--:-- 383
- 100 15.4M 100 15.4M 0 0 35739 0 0:07:32 0:07:32 --:--:-- 62373
- [root@topcheer ~]# chmod +x /usr/local/bin/docker-compose
- [[email protected] ~]# docker-compose
如果你联网下载比较慢, 我这边也提供了百度云链接, 下载赋权即可
https://pan.baidu.com/s/1-rn42OBPnUu16uF8xeNCQA
下载压缩包:
去 harbor 官网: https://goharbor.io/
点击 release, 下载 harbor 离线包, 这里选择最新版本的 1.8.0
下载下来的文件名为: harbor-offline-installer-v1.8.0.tgz
百度云: https://pan.baidu.com/s/1kguKaY43GJo_D9JcSdk2vw
解压:
- tar -zxvf harbor-offline-installer-v1.8.0.tgz
- ?
- -rw-r--r-- 1 root root 556153903 May 16 19:55 harbor.v1.8.0.tar.gz
- -rw-r--r-- 1 root root 4839 May 16 19:54 harbor.YAML
- -rwxr-xr-x 1 root root 5088 May 16 19:54 install.sh
- -rw-r--r-- 1 root root 11347 May 16 19:54 LICENSE
- -rwxr-xr-x 1 root root 1654 May 16 19:54 prepare
配置 harbor.YAML
较重要参数说明
hostname 目标主机的主机名, 用于访问 Portal 和注册表服务. 它应该是目标计算机的 IP 地址或完全限定的域名 (FQDN), 例如, 192.168.1.10 或 reg.yourdomain.com. 不要使用 localhost 或 127.0.0.1 作为主机名 - 外部客户端需要访问注册表服务
这里修改为我们的主机 ip 即可 例如修改为 10.10.55.55
data_volume: 存储 harbor 数据的位置. 这里可以修改 为 /usr/local/workspace/harbor/data
harbor_admin_password: 管理员的初始密码. 此密码仅在 Harbor 首次启动时生效. 之后, 将忽略此设置, 并且应在 Portal 中设置管理员密码. 请注意, 默认用户名 / 密码为 admin / Harbor12345.
关于端口配置:
http:
port: 你的 http 的端口号
https: 用于访问 Portal 和令牌 / 通知服务的协议. 如果启用了公证, 则必须设置为 https. 请参阅使用 HTTPS 访问配置 Harbor.
port:https 的端口号
certificate:SSL 证书的路径, 仅在协议设置为 https 时应用.
private_key:SSL 密钥的路径, 仅在协议设置为 https 时应用.
安装:
- # 执行 ./prepare
- ./prepare
- ?
- ?
- # 执行 ./install.sh
- ./install.sh# 查看启动情况 docker-compose ps
- ?
- [root@topcheer harbor]# docker-compose ps
- Name Command State Ports
- ---------------------------------------------------------------------------------------------
- harbor-core /harbor/start.sh Up (healthy)
- harbor-db /entrypoint.sh postgres Up (healthy) 5432/tcp
- harbor-jobservice /harbor/start.sh Up
- harbor-log /bin/sh -c /usr/local/bin/ ... Up (healthy) 127.0.0.1:1514->10514/tcp
- harbor-portal nginx -g daemon off; Up (healthy) 80/tcp
- nginx nginx -g daemon off; Up (healthy) 0.0.0.0:80->80/tcp
- Redis docker-entrypoint.sh Redis ... Up 6379/tcp
- registry /entrypoint.sh /etc/regist ... Up (healthy) 5000/tcp
- registryctl /harbor/start.sh Up (healthy)
- [root@topcheer harbor]#
使用:
配置免 https
方法一: 修改 /etc/docker/daemon.JSON
- vi /etc/docker/daemon.JSON# 加上 允许的仓库
- {
- "insecure-registries":[
- "192.168.180.105"
- ]
- }
方法二
- # 修改 docker.service
- cd /usr/lib/systemd/system
- ?
- vi docker.service
- ?
- ?
- # 修改 ExecStart, 添加 --insecure-registry 参数
- ExecStart=/usr/bin/dockerd --insecure-registry 192.168.180.105 -
两种方法都需要重启 docker 和 harbor
- # 重启 docker
- systemctl daemon-reload
- systemctl restart docker.service
- ?
- # 重启 harbor 仓库
- # cd 到 harbor 的安装目录
- cd /usr/local/workspace/harbor
- ?
- # 执行命令
- docker-compose stop
- docker-compose up -d
登录查看
新建公开项目 topcheer
4.3 上传镜像
- ?
- # 修改待上传镜像的 tag
- [[email protected] system]# docker tag nginx:latest 192.168.180.105/topcheer/nginx:1.1
- [[email protected] system]# docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- 192.168.180.105/topcheer/docker 1.0.1 4bc3d0f928cc 2 hours ago 643MB
- 192.168.180.105/topcheer/register-server 1.0.1 14ffc8c30b67 2 hours ago 731MB
- 192.168.180.105/topcheer/nginx 1.1 540a289bab6c 13 days ago 126MB
- # Linux 上登录 harbor 仓库
- # 10.10.xx.xx 表示 Linux 服务器地址, 请换成自己的服务器 ip# 注意要说明自己登陆哪个 ip, 不然默认会登陆 [[email protected] system]# docker login 127.0.0.1
- Username: admin
- Password:
- WARNING! Your password will be stored unencrypted in /root/.docker/config.JSON.
- Configure a credential helper to remove this warning. See
- https://docs.docker.com/engine/reference/commandline/login/#credentials-store
- ?
- Login Succeeded
- [root@topcheer system]# docker push 192.168.180.105/topcheer/nginx:1.1
- The push refers to repository [192.168.180.105/topcheer/nginx]
- a89b8f05da3a: Pushed
- 6eaad811af02: Pushed
- b67d19e65ef6: Pushed
- 1.1: digest: sha256:f56b43e9913cef097f246d65119df4eda1d61670f7f2ab720831a01f66f6ff9c size: 948
- [root@topcheer system]#
?
注: 别的 2 个是通过 maven 插件打包部署过来的, 后面一章在说明.
来源: http://www.bubuko.com/infodetail-3274040.html