5.6 Docker之Harbor搭建

1. Harbor搭建

Harbor官方文档:https://github.com/goharbor/harbor

1.下载Docker的单机编排工具(Docker compose),安装需添加docker-ce.repo源
[root@node02 ~]# yum -y install docker-compose 
[root@node02 ~]# cd /usr/src/

2.下载Harbor
[root@node02 src]# wget https://github.com/goharbor/harbor/releases/download/v1.10.2/harbor-offline-installer-v1.10.2.tgz
[root@node02 src]# ls
debug  harbor-offline-installer-v1.10.1.tgz  kernels

3.解压Harbor
[root@node02 src]# tar xf harbor-offline-installer-v1.10.1.tgz -C /usr/local/
[root@node02 src]# ls /usr/local/
bin  etc  games  harbor  include  lib  lib64  libexec  sbin  share  src
[root@node02 src]# cd /usr/local/harbor/
[root@node02 harbor]# ls
common.sh  harbor.v1.10.1.tar.gz  harbor.yml  install.sh  LICENSE  prepare

4.修改配置
[root@node02 harbor]# vim harbor.yml
...
hostname: node02-linux.example.com		#修改hostname为当前主机名

#若无HTTPS证书可注释以下几行
# 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: harbor123456	#在此修改harbor的admin管理员登录密码

# Harbor DB configuration
database:
  # The password for the root user of Harbor DB. Change this before any production use.
  password: root123456		#数据库密码
...

5.执行安装脚本,安装后使用80端口和1514端口
[root@node02 harbor]# ./install.sh
[root@node02 harbor]# ss -antl
State       Recv-Q Send-Q                   Local Address:Port                                  Peer Address:Port              
LISTEN      0      128                          127.0.0.1:1514                                             *:*                  
LISTEN      0      128                                  *:22                                               *:*                  
LISTEN      0      128                               [::]:80                                            [::]:*                  
LISTEN      0      128                               [::]:22

2. harbor操作

启动Harbor

[root@reg ~]# docker-compose start

2.1 harbor访问

在主机ip后加/harbor即可访问,用户名为admin,密码在配置中已设置
在这里插入图片描述
在这里插入图片描述

2.2 上传镜像

2.2.1 创建项目

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.2.2 上传镜像

1. 点击项目名称进入项目,点击镜像仓库,可点击推送镜像的DOCKER命令查看
在这里插入图片描述
在这里插入图片描述
2. 在主机中登录docker用户

[root@reg harbor]# docker login reg.docker.com
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

3. 修改镜像tag

[root@reg harbor]# docker images
REPOSITORY                      TAG                              IMAGE ID            CREATED             SIZE
httpd                           v0.3                             8c73b3847188        12 hours ago        187MB
[root@reg harbor]# docker tag httpd:v0.3 reg.docker.com/docker/httpd:v0.1
[root@reg harbor]# docker images
REPOSITORY                      TAG                              IMAGE ID            CREATED             SIZE
httpd                           v0.3                             8c73b3847188        12 hours ago        187MB
reg.docker.com/docker/httpd     v0.1                             8c73b3847188        12 hours ago        187MB

4. 添加搭建的Harbor加速器,地址为harbor主机名

[root@reg harbor]# cat /etc/docker/daemon.json 
{
  "registry-mirrors": ["http://reg.docker.com"],
  "registry-mirrors": ["https://41c6gj8l.mirror.aliyuncs.com"]
}
[root@reg harbor]# systemctl restart docker
[root@reg harbor]# docker-compose stop
Stopping harbor-jobservice ... done
Stopping nginx             ... done
Stopping harbor-core       ... done
Stopping harbor-db         ... done
Stopping redis             ... done
Stopping harbor-portal     ... done
Stopping registryctl       ... done
Stopping registry          ... done
Stopping harbor-log        ... done
[root@reg harbor]# ss -anlt
State       Recv-Q Send-Q                                 Local Address:Port                                                Peer Address:Port              
LISTEN      0      128                                                *:22                                                             *:*                  
[root@reg harbor]# docker-compose start
Starting log         ... done
Starting registry    ... done
Starting registryctl ... done
Starting postgresql  ... done
Starting portal      ... done
Starting redis       ... done
Starting core        ... done
Starting jobservice  ... done
Starting proxy       ... done
[root@reg harbor]# ss -anlt
State       Recv-Q Send-Q                                 Local Address:Port                                                Peer Address:Port              
LISTEN      0      128                                        127.0.0.1:1514                                                           *:*                  
LISTEN      0      128                                                *:22                                                             *:*                  
LISTEN      0      128                                             [::]:80                                                          [::]:* 

5. 上传镜像

[root@reg src]# docker push reg.docker.com/docker/httpd:v0.1
[root@reg harbor]# docker push reg.docker.com/docker/httpd:v0.1
The push refers to repository [reg.docker.com/docker/httpd]
85af3fcfec43: Mounted from harbor/httpd 
6daf13eee9fd: Mounted from harbor/httpd 
beee9f30bc1f: Mounted from harbor/httpd 
v0.1: digest: sha256:fbd88b62c5b2ce1bab362919662429ee14bb9081231d967638d77b0f28033bbb size: 951

6. 查看项目中镜像是否上传
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值