其他分享
首页 > 其他分享> > harbor简述

harbor简述

作者:互联网

harbor1 192.168.10.10
harbor2 192.168.10.11

harbor作为私有仓库被广泛使用。harbor依赖docker和docker-compose,所以要先安装docker和docker-compse。系统版本什么版本都可以

 

1安装docker和docker-compose,自行安装

2下载harbor,地址如下

https://github.com/goharbor/harbor/releases

此次下载的版本为1.8.2

3修改harbor配置(有的版本配置文件名是harbor.cfg)  hostname:可以是地址也可以是域名,域名自行解析,password:登录harbor的密码

 

 

 4启动安装脚本

 

 

 5.配置开机自启脚本

[root@c1 harbor]# cat /usr/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 /apps/harbor/docker-compose.yml up       自己的docker-compose.yml文件路径
ExecStop=/usr/bin/docker-compose -f /apps/harbor/docker-compose.yml down

[Install]
WantedBy=multi-user.target
[root@c1 src]# systemctl enable --now harbor

6 启动harbor

[root@c1 harbor]# docker-compose up

7修改docker启动文件

[root@c1 src]# grep -Ev '^$|#' /usr/lib/systemd/system/docker.service 
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
[Service]
Type=notify
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock  \
--insecure-registry 192.168.10.10 --insecure-registry 192.168.10.11 添加这两个参数,否则无法登录harbor,因为默认的是https ExecReload=/bin/kill -s HUP $MAINPID TimeoutSec=0 RestartSec=2 Restart=always StartLimitBurst=3 StartLimitInterval=60s LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity TasksMax=infinity Delegate=yes KillMode=process [Install] WantedBy=multi-user.target

[root@c1 src]# systemctl daemon-reload && systemctl restart docker

8登录harbor

[root@c1 src]# docker login 192.168.10.10
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

9登录web页面创建项目

 

 

 10上传镜像

[root@c1 harbor]# docker images |grep alpine
alpine                          latest                     961769676411        2 years ago         5.58MB
[root@c1 harbor]# docker tag alpine:latest 192.168.10.10/test1/alpine:latest          打tag,格式为harbor地址/项目名/镜像名
[root@c1 harbor]# docker push 192.168.10.10/test1/alpine:latest          上传镜像,不能上传执行docker login 192.168.10.10
The push refers to repository [192.168.10.10/test1/alpine]
03901b4a2ea8: Pushed 
latest: digest: sha256:acd3ca9941a85e8ed16515bfc5328e4e2f8c128caa72959a58a127b7801ee01f size: 528
[root@c1 harbor]# 


 


 

11 harbor高可用实现

在harbor2上同样安装docker,docker-compose,harbor,配置相同。不同点在于harbor的hostname为192.168.10.11。


harbor1配置如下

 

 

 

 

 

 

harbor2配置

 

 

 

 

 

 

 同步测试

harbor1上传镜像

[root@c1 ~]# docker tag nginx:1.14.2 192.168.10.10/test1/nginx:1.14.2
[root@c1 ~]# docker push 192.168.10.10/test1/nginx:1.14.2
The push refers to repository [192.168.10.10/test1/nginx]
82ae01d5004e: Pushed
b8f18c3b860b: Pushed
5dacd731af1b: Pushed
1.14.2: digest: sha256:706446e9c6667c0880d5da3f39c09a6c7d2114f5a5d6b74a2fafd24ae30d2078 size: 948
[root@c1 ~]#

harbor2也得到了nginx镜像

 

 

 

 

标签:harbor,192.168,简述,10.10,docker,root,c1
来源: https://www.cnblogs.com/ty111/p/16101262.html