搭建harbor倉庫
[root@harbor ~]# vim cat /etc/host
192.168.121.12 harbor
[root@harbor ~]# ?vim /etc/hostname
harbor
導入 harbor 項目鏡像
[root@harbor ~]# tar -zxf harbor-v2.9.2.tgz -C /usr/local/
[root@harbor ~]# cd /usr/local/harbor
[root@harbor harbor]# docker load -i harbor.v2.9.2.tar.gz
# 創建 https 證書, 本次使用http協議,所以需要創建證書
[root@harbor harbor]# mkdir tls
[root@harbor harbor]# openssl genrsa -out tls/cert.key 2048
[root@harbor harbor]# 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" \
修改配置文件
[root@harbor harbor]# cp harbor.yml.tmpl harbor.yml
[root@harbor harbor]# vim harbor.yml
如圖修改
hostname為本機ip
certificate: /usr/local/harbor/tls/cert.crt
private_key: /usr/local/harbor/tls/cert.key
harbor_admin_password: <登錄密碼>
?預安裝環境檢查,生成項目文件
[root@harbor harbor]# /usr/local/harbor/prepare
創建并啟動項目
[root@harbor harbor]# docker compose -f docker-compose.yml up -d
添加開機自啟動
[root@harbor harbor]# chmod 0755 /etc/rc.d/rc.local
[root@harbor harbor]# echo "/usr/bin/docker compose -p harbor start" >>/etc/rc.d/rc.local
安裝部署 docker 服務
[root@harbor ~]# dnf install -y docker-ce
# 配置鏡像加速器
[root@harbor ~]# vim /etc/docker/daemon.json
{
??? "registry-mirrors": ["https://harbor:443"],
??? "insecure-registries":["harbor:443"]
}
# 啟動服務
[root@harbor ~]# systemctl enable --now docker
# 查看 docker 服務配置信息
[root@harbor ~]# docker info
登錄倉庫:
[root@harbor ~]# docker login? harbor:443
Authenticating with existing credentials...
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/#credentials-store
Login Succeeded
出現Login Succeeded表示安裝成功
瀏覽器登錄:
搭建完成