[root@server1 ~]# unzip harbor-release-2.6.0.zip
[root@server1 ~]# mv harbor-2.6.0 /usr/local/
[root@server1 ~]# cd /usr/local/harbor-release-2.6.0/
修改配置文件
[root@server1 harbor-release-2.6.0]# cd make/
[root@server1 make]# cp harbor.yml.tmpl harbor.yml
[root@server1 make]# vim harbor.yml
[root@server1 make]# cat harbor.yml|grep -Ev "#|^$"
# #修改成自己的主机ip,如果在公网,则添加能访问到该主机的域名
hostname: 192.168.47.101
#默认是80端口,可以修改成自己想设置的端口
http:
port: 80
#修改为你要设置的密码
harbor_admin_password: 123456
# 注释https
#https:
# port: 443
# certificate: /your/certificate/path
# private_key: /your/private/key/path
修改daemon.json文件(在所有需要访问harbor的主机上!!!!!)
[root@server1 ~]# vim /etc/docker/daemon.json
[root@server1 ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://hzfyo6gg.mirror.aliyuncs.com"],
"insecure-registries":["192.168.47.101:80"]
}
安装
[root@server1 make]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 20.10.18
[Step 1]: checking docker-compose is installed ...
/usr/local/harbor-2.6.0/make/common.sh:行119: docker-compose: 未找到命令
✖ Failed to parse docker-compose version.
传入docker-compose可执行文件
[root@k8s-node1 make]# chmod +x docker-compose
[root@k8s-node1 make]# mv docker-compose /usr/bin/
[root@k8s-node1 make]# ./install.sh
[Step 4]: starting Harbor ...
Creating network "make_harbor" with the default driver
Pulling log (goharbor/harbor-log:v2.7.0-build.1572)...
ERROR: manifest for goharbor/harbor-log:v2.7.0-build.1572 not found: manifest unknown: manifest unknown
命令:./install.sh
报错:ERROR: manifest for goharbor/harbor-log:v2.7.0-build.1572 not found: manifest unknown: manifest unknown
原因:随着版本的更新发布,需要修改安装文件
解决:将报错信息的版本号替换为自己安装的版本号,具体步骤如下
[root@k8s-node1 make]# vim install.sh 找到行 ./prepare $prepare_para 在下面添加 sed -i "s/v2.7.0-build.1572/v2.6.0/g" docker-compose.yml
[root@k8s-node1 make]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 20.10.18
[Step 1]: checking docker-compose is installed ...
Note: docker-compose version: 1.23.2
[Step 2]: preparing environment ...
[Step 3]: preparing harbor configs ...
prepare base dir is set to /usr/local/harbor-2.6.0/make
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade
Clearing the configuration file: /config/portal/nginx.conf
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/registry/passwd
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
loaded secret from file: /data/secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
Note: stopping existing Harbor instance ...
Removing network make_harbor
[Step 4]: starting Harbor ...
Creating network "make_harbor" with the default driver
Pulling log (goharbor/harbor-log:v2.6.0)...
v2.6.0: Pulling from goharbor/harbor-log
...漫长的镜像拉取
d28e100d9e5c: Already exists
a0af95233d42: Pull complete
Creating harbor-log ... done
Creating registry ... done
Creating harbor-portal ... done
Creating harbor-db ... done
Creating redis ... done
Creating registryctl ... done
Creating harbor-core ... done
Creating nginx ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----
设置开机自启
[root@k8s-node1 make]# pwd
/usr/local/harbor-2.6.0/make
[root@k8s-node1 make]# vim /lib/systemd/system/harbor.service
[root@k8s-node1 make]# cat /lib/systemd/system/harbor.service
[Unit]
Description=Harbor
After=docker.service systemd-networkd.service systemd-resolved.service
Requires=docker.service
Documentation=http://github.com/vmware/harbor
[Service]
Type=simple
Restart=on-failure
RestartSec=5
ExecStart=/usr/bin/docker-compose -f /usr/local/harbor-2.6.0/make/docker-compose.yml up
ExecStop=/usr/bin/docker-compose -f /usr/local/harbor-2.6.0/make/docker-compose.yml down
[Install]
WantedBy=multi-user.target
[root@k8s-node1 make]# systemctl daemon-reload
[root@k8s-node1 make]# systemctl start harbor.service
[root@k8s-node1 make]# systemctl enable harbor.service
登陆harbor测试
[root@k8s-master ~]# docker login 192.168.47.101:80
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