harbor 仓库安装部署

配置修改主机名
hostnamectl set-hostname harbor
vim /etc/hosts
192.168.88.71 harbor
去掉干扰,卸载 Podman 和 docker-distribution
dnf remove -y podman docker-distribution
reboot

配置yum源
vim /etc/yum.repos.d/docker.repo
[Docker]
name=Rocky Linux $releasever - Docker Packages
baseurl="ftp://192.168.88.71/rpms"
enabled=1
gpgcheck=0

安装部署 docker
dnf install -y docker-ce
systemctl enable --now docker

导入 harbor 项目镜像
docker load -i harbor.v2.9.2.tar.gz

创建 https 证书
mkdir tls
openssl genrsa -out tls/cert.key 2048
openssl req -new -x509 -days 3652 -key tls/cert.key -out tls/cert.crt
-subj "/C=CN/ST=BJ/L=BJ/O=Tedu/OU=NSD/CN=harbor"
-addext "subjectAltName = IP:192.168.88.71"

修改配置文件
cp harbor.yml.tmpl harbor.yml
vim harbor.yml
05: hostname: 192.168.88.71
08: # http:
10: # port: 80
17: certificate: /usr/local/harbor/tls/cert.crt
18: private_key: /usr/local/harbor/tls/cert.key
36: harbor_admin_password: <登录密码>

预安装环境检查,生成项目文件
/usr/local/harbor/prepare

创建并启动项目
docker compose -f docker-compose.yml up -d

添加开机自启动
chmod 0755 /etc/rc.d/rc.local
echo "/usr/bin/docker compose -p harbor start" >>/etc/rc.d/rc.local

查看项目
docker compose ls -a
NAME STATUS CONFIG FILES
harbor running(9) /usr/local/harbor/docker-compose.yml

查看容器状态
docker compose -p harbor ps
NAME COMMAND SERVICE STATUS
harbor-core "/harbor/entrypoint.…" core running (healthy)
harbor-db "/docker-entrypoint.…" postgresql running (healthy)
harbor-jobservice "/harbor/entrypoint.…" jobservice running (healthy)
harbor-log "/bin/sh -c /usr/loc…" log running (healthy)
harbor-portal "nginx -g 'daemon of…" portal running (healthy)
nginx "nginx -g 'daemon of…" proxy running (healthy)
redis "redis-server /etc/r…" redis running (healthy)
registry "/home/harbor/entryp…" registry running (healthy)
registryctl "/home/harbor/start.…" registryctl running (healthy)

查看容器状态
docker compose -p harbor ps

posted @ 2025-07-09 21:30  油炸小趴菜  阅读(42)  评论(0)    收藏  举报