一、基础环境需求
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
- 安装
./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