搭建 Harbor 镜像存储仓库服务
[TOC]
1 申请阿里云 SSL 证书
由于之前在阿里云注册过域名,阿里云提供了单域名的免费 SSL 证书,因此使用 harbor.iuskye.com
这个域名申请一个 Nginx 证书。
/root/certs/server.pem
/root/certs/server.key
2 安装 docker
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install -y docker-ce-20.10.8-3.el7
systemctl start docker
systemctl enable docker
3 安装 docker-compose
wget https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-linux-x86_64
chmod +x docker-compose-Linux-x86_64
mv docker-compose-Linux-x86_64 /usr/bin/docker-compose
docker-compose --help
4 安装 harbor
## 2023.08.29 更新:这里的包版本较老,请到官网下载最新安装包
wget https://oss.iuskye.com/article/2021-08-25/harbor-offline-installer-v2.3.2.tgz
tar zxf harbor-offline-installer-v2.3.2.tgz
cd harbor
cp harbor.yml.tmpl harbor.yml
修改几个值:
vim harbor.yml
hostname: harbor.iuskye.com
https:
# https port for harbor, default is 443
port: 443
# The path of cert and key files for nginx
certificate: /root/certs/server.pem
private_key: /root/certs/server.key
./install.sh
5 通过浏览器访问
https://harbor.iuskye.com
。
账号密码可以从 harbor.yml
文件中查看到。
6 测试上传镜像
登录 Harbor:
docker login --username=admin harbor.iuskye.com
查看镜像:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.cn-beijing.aliyuncs.com/iuskye/kube-apiserver v1.21.3 3d174f00aa39 5 weeks ago 126MB
重新打 tag:
docker tag registry.cn-beijing.aliyuncs.com/iuskye/kube-apiserver:v1.21.3 harbor.iuskye.com/k8s/kube-apiserver:v1.21.3
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
harbor.iuskye.com/k8s/kube-apiserver v1.21.3 3d174f00aa39 5 weeks ago 126MB
registry.cn-beijing.aliyuncs.com/iuskye/kube-apiserver v1.21.3 3d174f00aa39 5 weeks ago 126MB
推送镜像:
docker push harbor.iuskye.com/k8s/kube-apiserver:v1.21.3
Web 端查看上传的镜像: