1 确保系统已经安装docker
2 确保系统已经安装python2.7以上版本
3 安装docker-compose,docker容器管理工具,是habor的依赖之一。
下载二进制文件:docker-compose-Linux-x86_64-1.24.1
下载地址:https://github.com/docker/compose/releases/download/
将该该文件复制到/usr/local/bin/docker-compose
赋予文件执行权限:chmod +x /usr/local/bin/docker-compose
测试是否安装完成:
[root@toto5 images]# docker-compose -v
docker-compose version 1.24.1, build 4667896b # 显示版就是成功
4 安装habor
下载安装包:https://github.com/vmware/harbor/releases/download/v1.8.0/harbor-offline-installer-v1.8.0.tgz
解压文件:
tar zxf harbor-online-installer-v1.82.0.tgz -C /usr/local/
修改配置文件:harbor.yml
cd /usr/local/harbor/
vim harbor.yml
#只需要修改:
hostname: 172.25.13.150 #habbor安装的主机
port: 80 #端口 可以改成443 也可以不该 改成443 需要配置tls认证,我没该
harbor_admin_password: redhat #habor的登陆密码 可以改可以不改
安装启动habbor
在/usr/local/habor中执行安装启动脚本。
sh install.sh
#这个过程会比较长,分为三步。
- 1 检查运行环境
- 2 导入需要的镜像
- 3 运行容器
正常的话会提示安装成功并且运行。
检测:以下运行的容器全部up
[root@toto5 harbor]# docker-compose ps
Name Command State Ports
-----------------------------------------------------------------------------
harbor-core /harbor/start.sh Up (healthy)
harbor-db /entrypoint.sh Up (healthy) 5432/tcp
postgres
harbor-jobservice /harbor/start.sh Up
harbor-log /bin/sh -c Up (healthy) 127.0.0.1:1514->105
/usr/local/bin/ ... 14/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 Up 6379/tcp
redis ...
registry /entrypoint.sh Up (healthy) 5000/tcp
/etc/regist ...
registryctl /harbor/start.sh Up (healthy)
4 web界面访问。
http://172.25.13.150 #注意使用的是80端口,若是时用的是443端口,则需要https://
5 上传本地镜像到仓库
1 首先需要在habor界面创建一个项目:
Projects-----》+new Projects-----》填写名称 ,选中public。
2 然后客户端进行处理
第一个:登陆:
[root@foundation13 ~]# docker login 172.25.13.150
Username: admin
Password:
Error response from daemon: Get https://172.25.13.150/v2/: dial tcp 172.25.13.150:443: connect: connection refused
#由于上面安装habor的时候,使用的是80端口,但是docker目前默认使用的是443,造成的冲突。
处理办法:在客户端主机:
vim /etc/docker/daemon.json
{
"insecure-registries": ["172.25.13.150"] #指定在连接访问172.25.13.250的时候使用http协议
}
[root@foundation13 ~]# systemctl daemon-reload
[root@foundation13 ~]# systemctl restart docker
再次登陆应该就能成功:
[root@foundation13 ~]# docker login 172.25.13.150
Username: admin
Password:
Login Succeeded #登陆成功
3 修改需要上传的本地镜像的标签(固定的格式)
仓库ip/项目名称/镜像名称
修改标签:
docker tag pingcap/tidb:latest 172.25.13.150/toto/pingcap/tidb:v2
上传本地镜像:
[root@foundation13 ~]# docker push 172.25.13.150/toto/pingcap/tidb:v2
The push refers to repository [172.25.13.150/toto/pingcap/tidb]
b78df5aad9d8: Pushed
0ea8196daf00: Pushed
e98b96c128d3: Pushed
85d020e79761: Pushed
73046094a9b8: Pushed
v2: digest: sha256:ce76ceb2fc772f990f02827aed8fe82115cec594998e2b09ef658cc697986d05 size: 1575
4 在前端页面上查看上传的镜像
5 拉取已经上传的镜像
[root@foundation13 ~]# docker pull 172.25.13.150/toto/game2018:v2
v2: Pulling from toto/game2018
534e72e7cedc: Pull complete
f62e2f6dfeef: Pull complete
fe7db6293242: Pull complete
3f120f6a2bf8: Pull complete
4ba4e6930ea5: Pull complete
Digest: sha256:8a34fb9cb168c420604b6e5d32ca6d412cb0d533a826b313b190535c03fe9390
Status: Downloaded newer image for 172.25.13.150/toto/game2018:v2