安装Harbor
下载地址: github.com/vmware/harb…
安装文档: github.com/goharbor/ha…
安装 docker-compose 工具
[root@localhost mnt]#ls
docker-compose-Linux-x86_64-1.27.4
[root@localhost mnt]#cp docker-compose-Linux-x86_64-1.27.4 /usr/bin/docker-compose
[root@localhost mnt]#chmod +x /usr/bin/docker-compose
[root@localhost mnt]#docker-compose version
docker-compose version 1.27.4, build 40524192
docker-py version: 4.3.1
CPython version: 3.7.7
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
准备 Harbor软件
[root@localhost data]#tar xf harbor-offline-installer-v1.2.2.tgz
Harbor 工具介绍
[root@localhost data]#cd harbor/
[root@localhost harbor]#
[root@localhost harbor]#ls
common docker-compose.notary.yml harbor_1_1_0_template harbor.v1.2.2.tar.gz LICENSE prepare
docker-compose.clair.yml docker-compose.yml harbor.cfg install.sh NOTICE upgrade
修改Harbor 配置文件
[root@localhost harbor]#vim harbor.cfg
5 hostname = 192.168.91.106 # 主机
69 harbor_admin_password = 123456 # 密码
安装前准备
如果是快照还原先重启docker
防火墙
selinux
准备配置文件
[root@localhost harbor]#./prepare
Generated and saved secret to file: /data/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/ui/env
Generated configuration file: ./common/config/registry/config.yml
Generated configuration file: ./common/config/db/env
Generated configuration file: ./common/config/jobservice/env
Generated configuration file: ./common/config/jobservice/app.conf
Generated configuration file: ./common/config/ui/app.conf
Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.
执行安装脚本
执行脚本前将 端口号占用的 清理清理
[root@localhost harbor]#./install.sh
Creating harbor-log ... done
Creating harbor-db ... done
Creating redis ... done
Creating registryctl ... done
Creating registry ... done
Creating harbor-adminserver ... done
Creating harbor-core ... done
Creating harbor-jobservice ... done
Creating harbor-portal ... done
Creating nginx ... done
✔ ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://192.168.91.106 .
For more details, please visit https://github.com/goharbor/harbor .
[root@localhost harbor]#docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
98d6b809adfb goharbor/nginx-photon:v1.7.6 "nginx -g 'daemon of…" 2 minutes ago Up 2 minutes (healthy) 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:4443->4443/tcp, :::4443->4443/tcp nginx
11e9893e9d5b goharbor/harbor-portal:v1.7.6 "nginx -g 'daemon of…" 2 minutes ago Up 2 minutes (healthy) 80/tcp harbor-portal
75c67093bdb3 goharbor/harbor-jobservice:v1.7.6 "/harbor/start.sh" 2 minutes ago Up 2 minutes harbor-jobservice
13fbbdd28084 goharbor/harbor-core:v1.7.6 "/harbor/start.sh" 2 minutes ago Up 2 minutes (healthy) harbor-core
7fd98c9ff339 goharbor/registry-photon:v2.6.2-v1.7.6 "/entrypoint.sh /etc…" 2 minutes ago Up 2 minutes (healthy) 5000/tcp registry
c6ea938cde84 goharbor/harbor-adminserver:v1.7.6 "/harbor/start.sh" 2 minutes ago Up 2 minutes (healthy) harbor-adminserver
37dee6cfb7eb goharbor/harbor-registryctl:v1.7.6 "/harbor/start.sh" 2 minutes ago Up 2 minutes (healthy) registryctl
cb4f4e1c3445 goharbor/redis-photon:v1.7.6 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 6379/tcp redis
3836bf4395b9 goharbor/harbor-db:v1.7.6 "/entrypoint.sh post…" 2 minutes ago Up 2 minutes (healthy) 5432/tcp harbor-db
e74a35ab4f00 goharbor/harbor-log:v1.7.6 "/bin/sh -c /usr/loc…" 2 minutes ago Up 2 minutes (health: starting) 127.0.0.1:1514->10514/tcp harbor-log
web端操作
登录
用户名: admin 密码: 之前配置文件中修改的
新建项目
命令行登录
默认是走https 协议无法登录
[root@localhost ~]# docker login 192.168.91.106
Username: admin
Password:
Error response from daemon: Get "https://192.168.91.106/v2/": dial tcp 192.168.91.106:443: connect: connection refused
需要修改 service 文件
[root@localhost ~]# vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry 192.168.91.106 --insecure-registry 192.168.91.107
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker login 192.168.91.106
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@localhost ~]# cat /root/.docker/config.json
{
"auths": {
"192.168.91.106": {
"auth": "YWRtaW46MTIzNDU2"
}
}
测试上传仓库
[root@localhost ~]# docker pull nginx
#下载镜像
打 上标签
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 2 years ago 141MB
[root@localhost ~]# docker tag 605c77e624dd 192.168.91.106/test/nginx:latest
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.91.106/test/nginx latest 605c77e624dd 2 years ago 141MB
nginx latest 605c77e624dd 2 years ago 141MB
上传
[root@localhost ~]# docker push 192.168.91.106/test/nginx:latest
The push refers to repository [192.168.91.106/test/nginx]
d874fd2bc83b: Pushed
32ce5f6a5106: Pushed
f1db227348d0: Pushed
b8d6e692a25e: Pushed
e379e8aedd4d: Pushed
2edcec3590a4: Pushed
latest: digest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3 size: 1570