1.安装docker-compose工具
#安装epel-release扩展源 yum -y install epel-release #安装Python-pip工具 yum -y install python-pip #升级Python-pip工具 pip install --upgrade pip #将docker-compose文件拷贝到/usr/local/bin/下 cp docker-compose /usr/local/bin/docker-compose #添加脚本执行权限 chmod +x /usr/local/bin/docker-compose #查看版本信息 docker-compose --v
需要用到的docker-compose工具 和Harbor安装包
链接:https://pan.baidu.com/s/1BuT8uMuajTzp-n1ji8vUlg
提取码:zhao
2、安装harbor
#将harbor-offline-installer-v1.7.0.tgz软件包上传到服务器上并解压得到harbor目录 [root@node2 ~]# ls docker-compose harbor-offline-installer-v1.7.0.tgz harbor #然后进入到harbor目录下,编辑harbor.cfg文件 [root@node2 ~]# cd harbor [root@node2 harbor]# vim harbor.cfg #将hostname改成本机IP,保存文件并退出 hostname = 192.168.164.11 #接下来执行./install.sh安装 [root@node2 harbor]# ./install.sh #安装完成会出现以下信息 [Step 3]: checking existing instance of Harbor ... Creating registry ... done Creating harbor-core ... done [Step 4]: starting Harbor ... Creating harbor-portal ... done Creating nginx ... done Creating harbor-adminserver ... Creating registryctl ... Creating harbor-db ... Creating registry ... Creating redis ... Creating harbor-core ... Creating harbor-portal ... Creating harbor-jobservice ... Creating nginx ... ✔ ----Harbor has been installed and started successfully.---- Now you should be able to visit the admin portal at http://192.168.164.11. For more details, please visit https://github.com/goharbor/harbor .
3、登录Harbor平台,默认用户名admin,密码Harbor12345
点击用户管理,创建一个用户user1,后面往harbor仓库上传镜像用得到。
然后将用户关联项目,将刚刚建的用户添加到library项目上
4、使用docker客户端上传镜像
[root@node2]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://b3uoq8jh.mirror.aliyuncs.com"], #原有的阿里云镜像加速
"insecure-registries":["192.168.164.11"] ##新添加这一行是私有镜像地址
}
重启 docker服务
systemctl restart docker
修改本地镜像tag 并将镜像上传到harbor 仓库
#本地镜像 [root@node2 harbor]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos7-ssh v1 3ffb5ab8e8de 18 hours ago 762MB busybox latest beae173ccac6 7 weeks ago 1.24MB nginx latest 605c77e624dd 7 weeks ago 141MB #先登录harbor仓库,用户名使用刚刚在web界面创建的用户 [root@node2 harbor]# docker login 192.168.164.11 Authenticating with existing credentials... 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 #修改镜像tag [root@node2 harbor]# docker tag nginx 192.168.164.11/library/nginx [root@node2 harbor]# docker tag busybox 192.168.164.11/library/busybox [root@node2 harbor]# docker tag centos7-ssh:v1 192.168.164.11/library/centos7-ssh:v1 #上传镜像 [root@node2 harbor]# docker push 192.168.164.11/library/nginx Using default tag: latest The push refers to repository [192.168.164.11/library/nginx] d874fd2bc83b: Pushed 32ce5f6a5106: Pushed f1db227348d0: Pushed b8d6e692a25e: Pushed e379e8aedd4d: Pushed 2edcec3590a4: Pushed latest: digest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3 size: 1570 [root@node2 harbor]# docker push 192.168.164.11/library/busybox [root@node2 harbor]# docker push 192.168.164.11/library/centos7-ssh:v1
5、登录harbor web界面查看镜像是否上传成功
这样harbor仓库就配置好了。



