- 配置环境
ip | 环境 |
---|---|
20.0.0.21 | harbor |
20.0.0.20 | node |
注意:Harbor的所有服务组件都是在Docker中部署的,所以官方安装使用Docker-compose快速部署,所以我们需要安装Docker、Docker-compose。由于Harbor是基于Docker Registry V2版本,所以就要求Docker版本不小于1.10.0,Docker-compose版本不小于1.6.0
在20.0.0.21服务器上配置
- 部署compose服务
Harbor 被部署为多个 Docker 容器,因此可以部署在任何支持 Docker 的 Linux 发行版 上。
服务端主机需要安装 Python(自带python2.6版本)、Docker 和 Docker Compose。
先把compose环境部署好:
docker-compose工具上传上去
chmod +x docker-compose //给执行权限
mv docker-compose /usr/bin/ //让系统所能识别
1、下载 Harbor 安装程序
把harboy包上传上去
tar zxvf harbor-offline-installer-v1.2.2.tgz -C /usr/local/ //直接解压到usr/local/
2、配置Harboy参数文件
vim /usr/local/harbor/harbor.cfg
5行 hostname = 20.0.0.21 //改成本地ip地址
59行还有默认登录密码
3、启动Harboy
cd /usr/local/harbor/
./install.sh //注意:每次更改配置后,都需要重新安装!!!
docker ps -a //七个容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1b33dfba6178 vmware/harbor-jobservice:v1.2.2 "/harbor/harbor_jobs…" 10 seconds ago Up 9 seconds harbor-jobservice
2de3f56ce99d vmware/nginx-photon:1.11.13 "nginx -g 'daemon of…" 10 seconds ago Up 9 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp nginx
717a97441ca4 vmware/harbor-ui:v1.2.2 "/harbor/harbor_ui" 10 seconds ago Up 10 seconds harbor-ui
0877caafd78c vmware/harbor-adminserver:v1.2.2 "/harbor/harbor_admi…" 12 seconds ago Up 11 seconds harbor-adminserver
8e4383af2565 vmware/registry:2.6.2-photon "/entrypoint.sh serv…" 12 seconds ago Up 11 seconds 5000/tcp registry
3b1c2d2ea9f4 vmware/harbor-db:v1.2.2 "docker-entrypoint.s…" 12 seconds ago Up 11 seconds 3306/tcp harbor-db
6b456c175f3d vmware/harbor-log:v1.2.2 "/bin/sh -c 'crond &…" 12 seconds ago Up 12 seconds 127.0.0.1:1514->514/tcp
浏览器输入20.0.0.21
账号:admin
密码:Harbor12345
//用管理员登录
docker login -u admin -p Harbor12345 http://127.0.0.1 //http协议登录
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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
//下载镜像进行测试
docker pull tomcat
//镜像打标签
docker tag tomcat:latest 20.0.0.21/zjz/tomcat
//上传镜像到harbor
docker push 127.0.0.1/zjz/tomcat //会拒绝你上传,解决方法在下面node节点上!!!
The push refers to repository [127.0.0.1/zjz/tomcat]
An image does not exist locally with the tag: 20.0.0.21/zjz/tomcat
在20.0.0.20服务器上配置
- 在node服务器上
解决上面不能上传的问题!!!
出现这问题的原因 Docker Registry 交互默认使用的是 HTTPS,但是搭建私有镜
像默认使用的是 HTTP 服务,所以与私有镜像交互时出现以下错误。
docker pull nginx //安装一个nginx,等会上传用
vim /usr/lib/systemd/system/docker.service
14行 ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry 20.0.0.21 --containerd=/run/cont ainerd/containerd.sock //添加--insecure-registry 20.0.0.21 这句,意思是指向仓库的Ip地址(位置)
systemctl daemon-reload //重载服务
systemctl restart docker //重启docker
docker login -u admin -p Harbor12345 http://20.0.0.21 //要上传先登录
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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
//镜像打标签
docker tag nginx:latest 20.0.0.21/zjz/nginx
//上传镜像到harbor
docker push 20.0.0.21/zjz/nginx
//删除掉nginx镜像
docker rmi nginx:latest
//从仓库下载
docker pull 20.0.0.21/zjz/nginx:latest
//就能看见nginx镜像了
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
20.0.0.21/zjz/nginx latest c39a868aad02 7 days ago 133MB
//去浏览器20.0.0.21,项目里的镜像仓库就会有nginx镜像。也会显示下载次数!!!
总结:整体配置很简单,也就是上传的那边要注意,解决办法已经在配置过程中写的很详细,注意查看