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)

相关推荐
多云的夏天11 分钟前
docker容器部署-windows-ubuntu
java·docker·容器
xlq2232231 分钟前
30.进程池IPC
linux·运维·服务器
nuomigege1 小时前
beagleboneblack刷入官方IOT镜像后无法运行nodered问题的处理
linux·运维·服务器
huaxiu51 小时前
ubuntu下应用打不开
linux·运维·ubuntu
@土豆1 小时前
k8s环境部署promethus及周边监控组件(复制粘贴就可完成部署)
云原生·容器·kubernetes
m0_683124791 小时前
Ubuntu服务设置开机自启
linux·运维·ubuntu
落叶花开又一年1 小时前
检验检测机构资质认定远程评审工作程序
linux·运维·服务器
wanhengidc1 小时前
《三国志异闻录》搬砖新游戏 云手机
运维·服务器·数据库·游戏·智能手机
i建模2 小时前
通过命令行使用密钥登录远程SSH主机
运维·ssh
旺仔.2912 小时前
僵死进程及Linux文件操作 详解
linux·运维·服务器