当前位置: 首页 > article >正文

Harbor部署docker私人仓库

1、新建虚拟机rhel9

2、配置网络

#修改内核参数使网卡名称为ethxxx
grubby --update-kernel ALL --args net.ifnames=0

reboot
#配置网络
vim /etc/NetworkManager/system-connections/eth0.connection
内容为:

[connection]
id=eth0
type=ethernet
interface-name=eth0

[ipv4]
method=manual
address1=172.25.254.250/24,172.25.254.2
dns=114.114.114.114

3、挂载本地软件仓库

#临时挂载
[root@localhost images]# mount /dev/sr0 /rhel9/

#永久挂载:编辑文件
[root@localhost images]# vim /etc/rc.d/rc.local 
内容:
mount /dev/sr0 /rhel9

#编辑本地源
vim /etc/yum.repos.d/rhel9.repo

内容:
[AppStream]
name=AppStream
baseurl=file:///rhel9/AppStream
gpgcheck=0

[BaseOS]
name=BaseOS
baseurl=file:///rhel9/BaseOS
gpgcheck=0

4、下载docker

[root@localhost images]# tar zxf docker.tar.gz
[root@localhost images]# dnf install *.rpm -y
[root@localhost images]# systemctl enable --now docker.service

5、挂载镜像

[root@localhost ~]# mkdir images

#将所需镜像全部放入images目录中
#全部挂载
[root@localhost images]# for i in `ls /root/images`; do docker load -i $i; done

6、生成证书

[root@localhost ~]# mkdir /data/certs -p
#创建证书
[root@localhost certs]# openssl req -newkey rsa:4096 -nodes -sha256 -keyout /data/certs/gaoyingjie.org.key -addext "subjectAltName = DNS:reg.gaoyingjie.org" -x509 -days 365 -out /data/certs/gaoyingjie.org.crt

#让docker读取证书
[root@localhost ~]# mkdir /etc/docker/certs.d/reg.gaoyingjie.org/ -p
[root@localhost ~]# cp /data/certs/gaoyingjie.org.crt /etc/docker/certs.d/reg.gaoyingjie.org/ca.crt
[root@localhost ~]# systemctl restart docker.service

7、部署harbor

[root@localhost ~]# tar zxf harbor-offline-installer-v2.5.4.tgz 
[root@localhost harbor]# cp harbor.yml.tmpl harbor.yml
[root@localhost harbor]# vim harbor.yml

内容:
hostname: reg.gaoyingjie.org
certificate: /data/certs/gaoyingjie.org.crt
private_key: /data/certs/gaoyingjie.org.key
harbor_admin_password: gyj

[root@localhost harbor]# ./install.sh  --with-chartmuseum
[root@localhost harbor]# docker compose stop
[root@localhost harbor]#  docker compose up -d

 8、建立登录认证

[root@localhost ~]# mkdir auth
[root@localhost ~]#  htpasswd -Bc auth/htpasswd gaoyingjie
New password: 
Re-type new password: 
Adding password for user gyj

9、编辑本地dns解析

#修改主机名:
hostnamectl hostname docker-harbor

#修改dns解析
[root@docker-harbor ~]# vim /etc/hosts

内容:
172.25.254.250 docker-harbor reg.gaoyingjie.org

10、登录harbor

[root@docker-harbor ~]#  docker login reg.gaoyingjie.org
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/#credential-stores

Login Succeeded

11、一键添加tag

[root@docker-harbor ~]# docker images | awk 'NR>1{system("docker tag "$1":"$2" reg.gaoyingjie.org/library/"$1":"$2)}'

12、一键push上传到harbor仓库

[root@docker-harbor ~]# docker images | awk '/reg.gaoyingjie.org/{system("docker push "$1":"$2)}'


http://www.kler.cn/a/287061.html

相关文章:

  • 解决conda create速度过慢的问题
  • Node.js的解释
  • leetcode 面试经典 150 题:合并区间
  • Axios 封装:处理重复调用与内容覆盖问题
  • TMC2208替代A4988
  • OpenCV简介、OpenCV安装
  • 解决npm下载依赖速度慢的问题
  • 用python启动nacos和redis
  • 蓝色炫酷碎粒子HTML5导航源码
  • (11)电调和电机
  • OSI七层网络协议
  • OceanBase 功能解析之 Binlog Service
  • 微信小程序引入unocss
  • 回溯——4.分割回文串
  • 【C++11及其特性】智能指针——auto_ptr
  • Java Operator SDK
  • YarnClient发送和接收请求源码解析
  • 深度学习复盘与论文复现G 项目维护
  • NTFS硬盘支持工具Paragon NTFS for Mac 15.4.44 中文破解版
  • 2024.9.1 Python,跳跃游戏,贪心算法,回溯算法复原 IP 地址,关于回溯过程中列表的[:]以及copy问题再讨论
  • Flowable之传阅功能实现
  • 今日算法:蓝桥杯基础题之“星期一”
  • easyExcel 单元格合并
  • C++开发基础之宏定义:入门、中级、高级用法示例解析
  • 计算机毕业设计选题推荐-体育馆场地预约系统-Java/Python项目实战
  • OpenHarmony开发:应用分层架构设计