Harbor-安装

一、安装前准备

CentOS 7.6+、Ubuntu 16.04.5+、Docker、Docker-compose

Docker安装查看:Docker-安裝_蚂蚁兄弟的博客-CSDN博客

二、安装Docker-compose

1、下载安装包

-- github不稳定情况下,可以选择如下路径
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

2、赋权

chmod +x /usr/local/bin/docker-compose

3、查看安装后的版本

docker-compose --version

三、安装Harbor

1、下载安装包

链接:百度网盘 请输入提取码 ​ 提取码:1234

将安装包上传到/opt/harbor路径下

2、修改配置

 解压安装包

tar -xvf /opt/harbor/harbor-offline-installer-v1.10.10\(最新版2022-02-21\).tgz

查看安装包结构

[root@localhost harbor]# ll
total 597988
-rw-r--r--. 1 root root      3398 Jan 12 12:08 common.sh
-rw-r--r--. 1 root root 612306524 Jan 12 12:09 harbor.v1.10.10.tar.gz
-rw-r--r--. 1 root root      5882 Jan 12 12:08 harbor.yml
-rwxr-xr-x. 1 root root      2284 Jan 12 12:08 install.sh
-rw-r--r--. 1 root root     11347 Jan 12 12:08 LICENSE
-rwxr-xr-x. 1 root root      1750 Jan 12 12:08 prepare

修改harbor.yml配置文件中的hostname为自己服务器地址

# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 192.168.91.132

注释配置文件内容

# https related config
#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

执行如下命令

[root@localhost harbor]# ./prepare 

开始安装

[root@localhost harbor]# ./install.sh 
............
[Step 5]: starting Harbor ...
[+] Running 10/10
 ⠿ Network harbor_harbor        Created  0.1s
 ⠿ Container harbor-log         Started  2.2s
 ⠿ Container harbor-db          Started  3.3s
 ⠿ Container registryctl        Started  3.3s
 ⠿ Container registry           Started  3.2s
 ⠿ Container harbor-portal      Started  3.1s
 ⠿ Container redis              Started  3.2s
 ⠿ Container harbor-core        Started  3.8s
 ⠿ Container harbor-jobservice  Started  4.4s
 ⠿ Container nginx              Started  4.5s
✔ ----Harbor has been installed and started successfully.----

安装完毕,使用浏览器访问:http://192.168.91.132/harbor 用户名/密码:admin/Harbor12345

 设置harbor开机自启

-- 添加自启服务
 vim /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/local/bin/docker-compose -f /opt/harbor/docker-compose.yml up
ExecStop=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml down
[Install]
WantedBy=multi-user.target

-- 保存设置
systemctl enable harbor

四、Docker客户端连接Harbor

1、配置Docker客户端

登录自己的Docker客户端,添加配置信息

vim /etc/docker/daemon.json

-- 添加如下
{
"registry-mirrors":["https://c05xby84.mirror.aliyuncs.com"],"insecure-registries":["192.168.91.132"]
}

重启docker

[root@localhost docker]# systemctl daemon-reload
[root@localhost docker]# systemctl restart docker
[root@localhost docker]# docker login 192.168.91.132
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

查看config文件,如下说明docker客户端配置成功

[root@localhost docker]# vi /root/.docker/config.json
{
        "auths": {
                "192.168.91.132": {
                        "auth": "YWRtaW46UGFzc0A5OAc2NTQz"
                }
        }
}

2、tag镜像

查看客户端的镜像

[root@localhost docker]# docker images
REPOSITORY              TAG       IMAGE ID       CREATED         SIZE
rancher/rancher-agent   v2.5.6    4cd72bf2d36b   13 months ago   517MB

tag镜像

[root@localhost docker]# docker tag rancher/rancher-agent:v2.5.6 192.168.91.132/library/rancher:v1
[root@localhost docker]# docker images
REPOSITORY                       TAG       IMAGE ID       CREATED         SIZE
192.168.91.132/library/rancher   v1        4cd72bf2d36b   13 months ago   517MB
rancher/rancher-agent            v2.5.6    4cd72bf2d36b   13 months ago   517MB

3、push镜像到Harbor

[root@localhost docker]# docker push 192.168.91.132/library/rancher:v1
The push refers to repository [192.168.91.132/library/rancher]
46d36fe48464: Pushed 
94ed4bd41523: Pushed 
21ee3a649795: Pushed 
19bad8fafcc4: Pushed 
2152f68efad9: Pushed 
19c323957156: Pushed 
2d72aa894140: Pushed 
07adad8f2cae: Pushed 
0dd1581dbc3c: Pushed 
837d6facb613: Pushed 
v1: digest: sha256:1f8fd1435f3fd352e512c311f28bd4df621e34230cda12064bb57e505cd670ec size: 2416

push成功后,登录harbor页面查看

 4、pull镜像

选择 复制 pull命令

在docker客户端执行复制的命令

[root@localhost ~]# docker pull 192.168.91.132/library/rancher:v1
v1: Pulling from library/rancher
92dc2a97ff99: Pull complete 
be13a9d27eb8: Pull complete 
c8299583700a: Pull complete 
6c4617fff611: Pull complete 
1a1a90b6ccfa: Pull complete 
ab7dedc984d5: Pull complete 
b808c0893715: Pull complete 
a6df9ab129a6: Pull complete 
ae8c5c35a8a8: Pull complete 
e6fc5f6b9112: Pull complete 
Digest: sha256:1f8fd1435f3fd352e512c311f28bd4df621e34230cda12064bb57e505cd670ec
Status: Downloaded newer image for 192.168.91.132/library/rancher:v1
192.168.91.132/library/rancher:v1

 五、Harbor卸载

删除Harbor相关目录、文件

rm -rf `find / -name harbor`

停止docker镜像

docker stop `docker ps -q`

删除全部镜像

docker rmi `docker images -q`
  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值