Docker私有镜像仓库(Harbor)安装

Docker私有镜像仓库(Harbor)安装

1、什么是Harbor

**Harbor是类似与DockerHub 一样的镜像仓库。**Harbor是由VMware公司开源的企业级的Docker Registry管理项目,它包括权限管理(RBAC)、LDAP、日志审核、管理界面、自我注册、镜像复制和中文支持等功能。Docker容器应用的开发和运行都需要的镜像管理,Docker官方虽然也提供了公共的镜像仓库,但是从安全和效率等方面考虑,特别是在企业级生产环境中,部署私有的Registry非常必要的。

更多详细介绍请看官网:GitHub - goharbor/harbor: An open source trusted cloud native registry project that stores, signs, and scans content.

其他不多说,请看以下全部实操演示。

2、安装环境准备

主机IP:192.168.40.6 内存至少2G

设置主机名

root@harbor \~# hostnamectl set-hostname harbor && bash

配置hosts文件

root@harbor \~# vi /etc/hosts

添加如下内容:

192.168.40.6 harbor

关闭防火墙

root@harbor \~# systemctl stop firewalld && systemctl disable firewalld

关闭selinux

root@harbor \~# setenforce 0

root@harbor \~# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

重启机器,selinux才能永久生效

root@harbor \~# reboot

配置时间同步

root@harbor \~# yum install -y ntp ntpdate

root@harbor \~# ntpdate cn.pool.ntp.org

3、docker安装

docker 安装的详细安装步骤,在其他博文中已有介绍,请看:

《Docker安装详细步骤》: Docker安装详细步骤_周十一.的博客-CSDN博客

4、Harbor安装步骤

Harbor自签发证书

我们这里是在自己的虚拟机上做实验,所以自签发证书,在实际生产中会买正式域名和相关证书

创建相关证书文件存放目录:

root@harbor \~# mkdir /data/ssl -p

root@harbor \~# mkdir /data/ssl -p

生成ca证书:

openssl如果不了解的,可以去官方看看,后面有机会在写介绍

生成一个3072位的key,ca私钥

root@harbor \~# openssl genrsa -out ca.key 3072

生成一个数字证书ca.pem,3650表示证书的有效时间为一年,

root@harbor \~# openssl req -new -x509 -days 365 -key ca.key -out ca.pem

生成域名的证书:

#生成一个3072位的key,harbor私钥

root@harbor \~# openssl genrsa -out harbor.key 3072

root@harbor \~# openssl req -new -key harbor.key -out harbor.csr

签发证书:

root@harbor \~# openssl x509 -req -in harbor.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out harbor.pem -days 365

查看生成的相关证书:

Harbor安装

创建安装目录

root@harbor \~# mkdir /data/install -p

root@harbor \~# cd /data/install/

下载Harbor 安装包:

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

本篇使用harbor-offline-installer-v2.3.0-rc3.tgz 安装包作为演示,下载成功后上传到/data/install/ 目录

解压安装文件:

root@harbor install# tar zxvf harbor-offline-installer-v2.3.0-rc3.tgz

修改配置文件:

root@harbor install# cd harbor

root@harbor harbor# cp harbor.yml.tmpl harbor.yml

root@harbor harbor# vi harbor.yml

修改上面两处内容,第一次修改上面我们自签发的域名harbor ,后面一次修改咱们相关证书的地址

其他参数 如果有需要大家可以自行修改,比如接口、内存、日志存放路径等等

在配置中还可以修改Harbor的默认密码:

账号/密码:admin/Harbor12345

上传docker-harbor-2-3-0.tar.gz 文件到安装目录

加载镜像:

root@harbor harbor# docker load -i docker-harbor-2-3-0.tar.gz

执行安装:

root@harbor harbor# cd /data/install/harbor

root@harbor harbor# ./install.sh

出现以上界面,表示已经安装成功,浏览器输入:http://192.168.40.6

相关推荐
饿了吃洗衣凝珠2 小时前
shell
linux·运维·服务器
Decay__4 小时前
PostgreSQL 性能调优方法论 —— pg_stat_statements、EXPLAIN ANALYZE、瓶颈定位流程与参数基线
运维·数据库·sql·postgresql
always20226 小时前
AI运行时 · 06 - Kata 与 K8s 集成:RuntimeClass / CSI kata-directvolume / 性能开销与调优
人工智能·容器·kubernetes
stormsha9 小时前
中文路径让 MySQL 起不来:Failed to find valid data directory 与 Illegal byte sequence
运维·数据库·mysql
stormsha9 小时前
MySQL 报 `data directory has files in it`:初始化失败一次,之后就永久起不来
运维·数据库·mysql
csdn_aspnet11 小时前
使用 Docker 配置 PostgreSQL 和 pgAdmin 4
数据库·docker·postgresql·pgadmin4
Maiko Star12 小时前
Docker保姆级部署AI应用程序(FastAPI)
docker·容器·fastapi
沙老师14 小时前
Linux Purification Plan - More Modification
linux·运维·服务器
Decay__15 小时前
PostgreSQL 高可用与容灾架构 —— 流复制、Patroni、Keepalived+VIP、读写分离与两地三中心
运维·数据库·sql·postgresql
A-刘晨阳1 天前
Kubernetes 查询证书有效期及续签证书(适用于二进制部署)
云原生·容器·kubernetes·证书·cfssl