企业级Harbor私有仓库搭建

一、基础环境需求

harbor是由VMware公司的中国团队开发的。私有的docker镜像仓库。

https://hub.docker.com/ #官方镜像仓库
https://registry.cn-hangzhou.aliyuncs.com #第三方镜像仓库 Harbor
#私有的docker镜像仓库

官网私有docker镜像仓库下载地址:https://goharbor.io/
Harbor被部署为多个Docker容器。因此,您可以将其部署在任何支持Docker的Linux发行版上。
目标主机要求安装Docker和Docker Compose。

硬件要求
在这里插入图片描述
软件要求

在这里插入图片描述
网络端口
在这里插入图片描述

二、安装部署habor

1.安装基础源

#安装Base源
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
#安装epel源
[root@localhost ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
[root@localhost ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

#清除及建立缓存
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache

2.安装docker
先卸载旧版本docker

yum list installed|grep docker

yum remove xxx

查看docker版本

 yum list docker-ce --showduplicates | sort -r
 * updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
 * extras: mirrors.aliyun.com
docker-ce.x86_64            3:20.10.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.12-3.el7                    docker-ce-stable
docker-ce.x86_64            3:20.10.11-3.el7                    docker-ce-stable
docker-ce.x86_64            3:20.10.10-3.el7                    docker-ce-stable
docker-ce.x86_64            3:20.10.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.15-3.el7                    docker-ce-stable


安装 19.03.9版本

yum -y install docker-ce-3:19.03.9-3.el7

配置docker阿里云加速,略

3.安装docker-compose
见上文

4.安装Openssl

yum install openssl openssl-devel -y

5.下载harbor

手动下载地址 https://github.com/goharbor/harbor/releases
下载如下版本
harbor-offline-installer-v2.4.1.tgz

下载比较慢,使用百度云盘下载
链接:https://pan.baidu.com/s/176XObl33jkZ50gCNItGwyg
提取码:1234

6.解压

tar -xf harbor-offline-installer-v2.4.1.tgz -C /usr/local

7.去阿里云上申请对应域名的nginx证书,保存在本地的/data/cert目录下

[root@harbor harbor]# ll /data/cert/
total 8
-rw-r--r-- 1 root root 1675 Dec 28 14:38 6872527_harbor.bertwu.online.key
-rw-r--r-- 1 root root 3813 Dec 28 14:38 6872527_harbor.bertwu.online.pem

7.修改harbor配置文件

cd /usr/local/harbor
# 修改配置文件
cp harbor.yml.tmpl harbor.yml
vim harbor.yml

在这里插入图片描述
8.加载镜像

docker load < harbor.v2.4.1.tar.gz 

在这里插入图片描述
9.生成配置文件

./prepare
  1. 安装
./install.sh

11.检查启动的镜像
在这里插入图片描述

12.配置hosts文件。浏览器访问https

harbor.bertwu.onlein
用户名:admin
密码: Harbor12345

在这里插入图片描述

三、harbor操作

1.修改配置
在这里插入图片描述
2.配置邮箱
在这里插入图片描述

在这里插入图片描述
3.创建项目
在这里插入图片描述
4.往项目中远程推送镜像
在这里插入图片描述

docker tag SOURCE_IMAGE[:TAG] harbor.bertwu.online/beijing/REPOSITORY[:TAG]
docker push harbor.bertwu.online/beijing/REPOSITORY[:TAG]

具体如下:

打包镜像

[root@localhost ~]# docker tag nginx:latest  harbor.bertwu.online/beijing/nginx:1.

[root@localhost ~]# docker images | grep harbor
harbor.bertwu.online/beijing/nginx   1.20.1          f652ca386ed1   3 weeks ago     141MB

登录harbor仓库

[root@localhost ~]# docker login harbor.bertwu.online
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@localhost ~]# docker push harbor.bertwu.online/beijing/nginx:1.20.1
The push refers to repository [harbor.bertwu.online/beijing/nginx]
2bed47a66c07: Pushed 
82caad489ad7: Pushed 
d3e1dca44e82: Pushed 
c9fcd9c6ced8: Pushed 
0664b7821b60: Pushed 
9321ff862abb: Pushed 
1.20.1: digest: sha256:4424e31f2c366108433ecca7890ad527b243361577180dfd9a5bb36e828abf47 size: 1570
[root@localhost ~]# 

刷新仓库查看是否推送成功
在这里插入图片描述
拉取镜像
点击如下拉取按钮复制命令,如果是私有仓库,拉取时需要命令行登录harbor
在这里插入图片描述

docker pull harbor.bertwu.online/beijing/nginx:1.20.1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值