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

[root@localhost system-connections]# chmod 600 eth0.nmconnection 
[root@localhost system-connections]# nmcli connection reload 
[root@localhost system-connections]# nmcli connection up eth0 

3、挂载本地软件仓库

复制代码
#临时挂载
[root@localhost ~]# mkdir /rhel9
[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 ~]# cd harbor/
[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

#编辑本地解析
[root@localhost harbor]# vim /etc/hosts
172.25.254.250  docker-harbor reg.gaoyingjie.org

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)}'
相关推荐
AI小小怪4 小时前
在Linux服务器上安装CVAT (Docker 28.5.1)
运维·docker·容器·数据标注·cvat
小坏讲微服务5 小时前
Docker-compose 搭建Maven私服部署
java·spring boot·后端·docker·微服务·容器·maven
!chen6 小时前
k8s-Pod中的网络通信
网络·docker·kubernetes
KYGALYX7 小时前
在Linux中备份msyql数据库和表的详细操作
linux·运维·数据库
余—笙7 小时前
Linux(docker)安装搭建CuteHttpFileServer/chfs文件共享服务器
linux·服务器·docker
lang201509287 小时前
Linux高效备份:tar与gzip完全指南
linux·运维·服务器
奥尔特星云大使8 小时前
《系统规划与管理师教程(第2版)》方法篇 第10章 云原生系统规划 知识点总结
云原生·软考·高级·系规
wanhengidc8 小时前
云手机的基本原理
运维·服务器·游戏·智能手机·云计算
篙芷8 小时前
两台服务器 NFS 共享目录实战
运维·服务器
芥子沫8 小时前
《玩转Docker》[应用篇13]:Docker安装部署Emby及使用技巧:家庭媒体服务器
docker·视频·emby