1.先安装好最新版的docker环境( 最新版默认安装了docker compose )
2.到官网下载最新harbor安装包(最新版)
https://github.com/goharbor/harbor/releases/download/v2.8.3/harbor-offline-installer-v2.8.3.tgz
3.将安装包上传到虚拟机中,进行解压
[root@docker-2 harbor]# tar xf harbor-offline-installer-v2.8.3.tgz
[root@docker-2 harbor]# ls
harbor harbor-offline-installer-v2.8.3.tgz
[root@docker-2 harbor]# cd harbor[root@docker-2 harbor]# ls
common docker-compose.yml install.sh prepare
common.sh harbor.v2.8.3.tar.gz harbor.yml.tmpl LICENSE
4.将harbor.yml.tmpl文件复制一份并改名为harbor.yml
[root@docker-2 harbor]# cp harbor.yml.tmpl harbor.yml
[root@docker-2 harbor]# ls
common docker-compose.yml harbor.yml install.sh prepare
common.sh harbor.v2.8.3.tar.gz harbor.yml.tmpl LICENSE
5.更改配置文件harbor.yml
[root@docker-2 harbor]# vim harbor.yml
hostname: 192.168.118.138 #更改为自己主机的ip地址
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 8079 #并设置端口为8079,防止与其他进程冲突harbor_admin_password: 123456 #记住这个密码,等下登陆要用
6.执行harbor自动安装可执行文件(全部started才算成功)
[root@docker-2 harbor]# ./install.sh
[Step 5]: starting Harbor ...
[+] Running 10/10
✔ Network harbor_harbor Created 0.1s
✔ Container harbor-log Started 0.4s
✔ Container registry Started 1.1s
✔ Container harbor-db Started 1.2s
✔ Container registryctl Started 1.0s
✔ Container harbor-portal Starte... 1.1s
✔ Container redis Started 0.8s
✔ Container harbor-core Started 1.5s
✔ Container nginx Started 2.0s
✔ Container harbor-jobservice St... 2.0s
✔ ----Harbor has been installed and started successfully.----
7.查看镜像启动情况
[root@docker-2 harbor]# docker compose ls
NAME STATUS CONFIG FILES
harbor running(9) /harbor/harbor/docker-compose.yml
8.去网页上访问192.168.118.138:8079(填你自己的ip地址) (确保你的防火墙已经关闭)
9.点击项目,新建自己的项目hello,设置10G
10.点击用户管理,新建用户superman
11.点击hello项目,添加成员superman
12.再用另一台有harbor的虚拟机client进行配置,镜像加速仓库
[root@docker-1 ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://naxm4z64.mirror.aliyuncs.com"],
"insecure-registries": ["192.168.118.138:8079"] #添加镜像加速私有地址
}[root@docker-1 ~]# systemctl daemon-reload #重新加载服务
13.在client端登录到 Docker 镜像仓库(自己的私有仓库) superman 用户 密码自己设的
[root@docker-1 ~]# docker login 192.168.118.138:8079
Username: superman
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-storeLogin Succeeded
14.client端拉取一个busybox镜像,打标签
[root@docker-1 ~]# docker pull busybox
[root@docker-1 ~]# docker tag busybox 192.168.118.138:8079/hello/busybox:9.9#格式一定要ip地址+端口号+hello项目+镜像名:tag
#不然找不到对应的私有仓库位置
[root@docker-1 ~]# docker images |tail -1
192.168.118.138:8079/hello/busybox 9.9 beae173ccac6 19 months ago 1.24MB
15.上传镜像到私有仓库
[root@docker-1 ~]# docker push 192.168.118.138:8079/hello/busybox:9.9
16.去Harbor查看是否有对应的镜像,如果有表示成功
17.再在client上拉取私有仓库的镜像(先把本地的镜像删除 docker rm 镜像名)
[root@docker-1 ~]# docker rmi 192.168.118.138:8079/hello/busybox:9.9
[root@docker-1 ~]# docker pull 192.168.118.138:8079/hello/busybox:9.9
#再进行拉取 ,最后查看本地镜像,是否拉取成功[root@docker-1 ~]# docker images |tail -3
192.168.118.138:8079/hello/busybox 9.9 beae173ccac6 19 months ago 1.24MB