搭建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表示安装成功
浏览器登录:
搭建完成