harbor仓库部署
Harbor - 企业级 Docker 私有仓库
安装前置环境
1: 安装必要的一些系统工具
yum install -y yum-utils device-mapper-persistent-data lvm2
2: 添加软件源信息
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3: 更新并安装Docker-CE
yum makecache fast
yum -y install docker-ce docker-compose
Harbor安装
Harbor官方地址
https://github.com/goharbor/harbor/tags
下载解压软件包
wget https://github.com/goharbor/harbor/releases/download/v2.0.3/harbor-offline-installer-v2.0.3.tgz
mkdir -p /harbor
tar xf harbor-offline-installer-v2.0.3.tgz -C /harbor/
cd /harbor/harbor/
cp harbor.yml.tmpl harbor.yml
配置https证书(有正式证书可忽略)
openssl genrsa -des3 -out server.key 2048
openssl req -new -key server.key -out server.csr
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
修改配置文件
[root@harbor harbor]# grep '^[a-Z ]' harbor.yml | grep -v ' #'
运行脚本进行安装
./install.sh
配置hosts解析(有正式域名可忽略)
C:\Windows\System32\drivers\etc\hosts
测试访问
账号密码(默认)
admin/Harbor12345
配置hosts(所有节点执行)
echo "10.0.0.64 xiaofei.com" >> /etc/hosts
其他需要使用仓库节点需配置
[root@node-02 ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"],
"insecure-registries": ["https://xiaofei.com"]
}
systemctl restart docker.service
登录仓库
docker login https://xiaofei.com
测试是否能成功上传镜像(前提有镜像)
docker tag nginx:alpine xiaofei.com/library/nginx:v1
其他节点测试拉取