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博客](https://blog.csdn.net/cainiaoxiaozhou/article/details/132598722?spm=1001.2014.3001.5502 "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 查看生成的相关证书: ![](https://file.jishuzhan.net/article/1697518613382041601/c8d1eab595c8487ba26142f11703f510.png) ### Harbor安装 创建安装目录 \[root@harbor \~\]# mkdir /data/install -p \[root@harbor \~\]# cd /data/install/ 下载Harbor 安装包: [https://github.com/goharbor/harbor/releases/tag/](https://github.com/goharbor/harbor/releases/tag/ "https://github.com/goharbor/harbor/releases/tag/") 本篇使用harbor-offline-installer-v2.3.0-rc3.tgz 安装包作为演示,下载成功后上传到/data/install/ 目录 ![](https://file.jishuzhan.net/article/1697518613382041601/ab1193a930304f9f87acad813f86198f.png) 解压安装文件: \[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 ![](https://file.jishuzhan.net/article/1697518613382041601/4138434fa8304d06a502663e3ec5adc5.png) 修改上面两处内容,第一次修改上面我们自签发的域名harbor ,后面一次修改咱们相关证书的地址 其他参数 如果有需要大家可以自行修改,比如接口、内存、日志存放路径等等 在配置中还可以修改Harbor的默认密码: ![](https://file.jishuzhan.net/article/1697518613382041601/b58dddc5bca04288a1ae32e0d9370f22.png) 账号/密码:admin/Harbor12345 上传docker-harbor-2-3-0.tar.gz 文件到安装目录 加载镜像: \[root@harbor harbor\]# docker load -i docker-harbor-2-3-0.tar.gz ![](https://file.jishuzhan.net/article/1697518613382041601/f63b9cfa67874ca49e27d21d02095538.png) 执行安装: \[root@harbor harbor\]# cd /data/install/harbor \[root@harbor harbor\]# ./install.sh ![](https://file.jishuzhan.net/article/1697518613382041601/0a788dcbffc34c088e3745bb9b96c32c.png) 出现以上界面,表示已经安装成功,浏览器输入:http://192.168.40.6 ![](https://file.jishuzhan.net/article/1697518613382041601/6b7edcde0cc24ec0831e767b229330cd.png)

相关推荐
乌托邦的逃亡者13 分钟前
Linux中如何检测IP冲突
linux·运维·tcp/ip
一曦的后花园23 分钟前
linux搭建promethes并对接node-exporter指标
linux·运维·服务器
乌托邦的逃亡者1 小时前
CentOS/Openeuler主机中,为一个网卡设置多个IP地址
linux·运维·网络·tcp/ip·centos
拾贰_C1 小时前
【OpenClaw | openai | QQ】 配置QQ qot机器人
运维·人工智能·ubuntu·面试·prompt
桌面运维家2 小时前
服务器进程异常监控:快速定位与排障实战指南
运维·服务器
Java后端的Ai之路2 小时前
Kubernetes是什么?(小白入门版)
云原生·容器·kubernetes·教程
风曦Kisaki2 小时前
# Linux Shell 编程入门 Day02:条件测试、if 判断、循环与随机数
linux·运维·chrome
木雷坞2 小时前
视觉算法环境 Docker 镜像拉取失败排查
运维·人工智能·docker·容器
郝亚军2 小时前
ubuntu 22.04如何安装libmodbus
运维·服务器·ubuntu
李日灐2 小时前
< 6 > Linux 自动化构建工具:makefile 详解 + 进度条实战小项目
linux·运维·服务器·后端·自动化·进度条·makefile