harbor单机安装
harbor官方网站:Harbor (goharbor.io)
harbor下载地址:https://github.com/goharbor/harbor/releases
下载
# cat /etc/os-release |sed -n 5p
PRETTY_NAME="Ubuntu 18.04.4 LTS"
# pwd
/usr/local/src
# ls
harbor-offline-installer-v2.8.4.tgz
解压
# tar xf harbor-offline-installer-v2.8.4.tgz
# ln -sv /usr/local/src/harbor /usr/local/
'/usr/local/harbor' -> '/usr/local/src/harbor'
配置
# ls
common.sh harbor.v2.8.4.tar.gz harbor.yml.tmpl install.sh LICENSE prepare
# cp -ar harbor.yml.tmpl harbor.yml
# vim harbor.yml
hostname: top.swthink.local
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 80
......
#如果没有此项设置,请注释掉
#https:
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
# certificate: /your/certificate/path
# private_key: /your/private/key/path
......
harbor_admin_password: 123456
........
解析此域名:top.swthink.local
# vim /etc/hosts
192.168.75.131 top.swthink.local
windows映射设置路径:C:\Windows\System32\drivers\etc\hosts
192.168.75.131 top.swthink.local
部署
/usr/local/src/harbor# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 24.0.2
[Step 1]: checking docker-compose is installed ...
Note: Docker Compose version v2.18.1
[Step 2]: loading Harbor images ...
Loaded image: goharbor/harbor-jobservice:v2.8.4
Loaded image: goharbor/redis-photon:v2.8.4
Loaded image: goharbor/harbor-log:v2.8.4
Loaded image: goharbor/harbor-db:v2.8.4
Loaded image: goharbor/nginx-photon:v2.8.4
Loaded image: goharbor/prepare:v2.8.4
Loaded image: goharbor/harbor-core:v2.8.4
Loaded image: goharbor/trivy-adapter-photon:v2.8.4
Loaded image: goharbor/harbor-portal:v2.8.4
Loaded image: goharbor/registry-photon:v2.8.4
Loaded image: goharbor/notary-server-photon:v2.8.4
Loaded image: goharbor/notary-signer-photon:v2.8.4
Loaded image: goharbor/harbor-registryctl:v2.8.4
Loaded image: goharbor/harbor-exporter:v2.8.4
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /usr/local/src/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
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
Generated and saved secret to file: /data/secret/keys/secretkey
Successfully called func: create_root_cert
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
Note: stopping existing Harbor instance ...
[Step 5]: starting Harbor ...
[+] Building 0.0s (0/0)
[+] Running 10/10
✔ Network harbor_harbor Created 0.1s
✔ Container harbor-log Started 1.6s
✔ Container registryctl Started 4.3s
✔ Container redis Started 3.4s
✔ Container harbor-portal Started 6.4s
✔ Container registry Started 5.4s
✔ Container harbor-db Started 7.1s
✔ Container harbor-core Started 8.1s
✔ Container harbor-jobservice Started 9.4s
✔ Container nginx Started 10.5s
✔ ----Harbor has been installed and started successfully.----
#如遇到检测环境当中没有安装docker-compose的话先安装
# apt-get install python3-pip
# pip install docker-compose
查看本地端口
root@ubuntu-n1:~# ss -ntl |grep 80
LISTEN 0 80 127.0.0.1:3306 0.0.0.0:*
LISTEN 0 128 *:80 *:*
访问
打开浏览器访问:http://top.swthink.local/
登录
账号:admin 密码:123456
新建项目
上传镜像
安全设置
上传镜像之前,先做个可以允许不安全访问设置,如下:
# vim /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry top.swthink.local #增加--insecure-registry top.swthink.local
#重启docker重启加载文件生效
# systemctl daemon-reload
# systemctl restart docker
#重启后harbor服务掉了,重启开启一下。
# docker compose -f /usr/local/src/harbor/docker-compose.yml up -d #-d后台运行
登录docker login
# docker login top.swthink.local
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@ubuntu-n1:~# cat /root/.docker/config.json
{
"auths": {
"registry.cn-hangzhou.aliyuncs.com": {
"auth": "c3d0aGluazY6c3dfNzMzMTcwMg=="
},
"top.swthink.local": { #此为当前登录的账号密码,在此保存
"auth": "YWRtaW46MTIzNDU2"
},
"top.swthink.local:5000": {
"auth": "YWRtaW46MTIzNDU2"
}
}
重新打标签
# docker tag registry.cn-hangzhou.aliyuncs.com/swthink/nginx:v1 top.swthink.local/nginx/nginx:v1.20.1
上传镜像
# docker push top.swthink.local/nginx/nginx:v1.20.1
The push refers to repository [top.swthink.local/nginx/nginx]
ea1c707d70dc: Mounted from web-nginx/nginx
c9e336ac6f75: Mounted from web-nginx/nginx
a38eb85e912e: Mounted from web-nginx/nginx
174f56854903: Mounted from web-nginx/nginx
v1.20.1: digest: sha256:a0a8e5ca7b2ce8a55ce8aeba54e3dacc22cc4e0d83dc6017f13a6c624131660b size: 1161
验证是否上传成功
OK!!!