Harbor私有仓库部署(最新)

本文档详细介绍了如何在CentOS系统上部署Harbor私有仓库,包括安装Docker、配置国内YUM源、下载并安装Harbor、设置docker-compose,以及将本地Docker镜像推送到Harbor仓库的过程。在推送上镜像时,需要注意先创建项目,否则会遇到权限问题。
摘要由CSDN通过智能技术生成

Harbor私有仓库部署(最新)

[root@K8s-Master ~]#yum install wget -y
[root@K8s-Master ~]#wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo #docker-ce国内yum源
[root@K8s-Master ~]#yum -y install docker-ce
[root@K8s-Master ~]#systemctl enable docker && systemctl start docker
[root@K8s-Master ~]# wget https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-offline-installer-v1.8.0.tgz                   #下载Harbor
[root@K8s-Master ~]# tar xf harbor-offline-installer-v1.8.0.tgz 
[root@K8s-Master ~]# cd harbor/
[root@K8s-Master harbor]# ls
harbor.v1.8.0.tar.gz  harbor.yml  install.sh  LICENSE  prepare

[root@K8s-Master ~]# wget https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)                           #下载docker-compose
[root@K8s-Master ~]# mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
[root@K8s-Master ~]# chmod +x /usr/local/bin/docker-compose

[root@K8s-Master harbor]# bash install.sh #安装harbor
[root@K8s-Master harbor]# docker-compose ps

#上传镜像
[root@k8s-node2 ~]# docker tag nginx:latest 192.168.66.11/project/nginx:test
[root@k8s-node2 ~]# docker images | grep nginx
nginx                                                latest    605c77e624dd   4 months ago    141MB
192.168.66.11/project/nginx                          test      605c77e624dd   4 months ago    141MB
[root@k8s-node2 ~]# cat /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://7w5yqlyj.mirror.aliyuncs.com"],
  "insecure-registries": ["http://192.168.66.11"],
  "graph": "/data/dockerdata/docker"  
}
[root@k8s-node2 ~]# systemctl daemon-reload  &&systemctl restart docker
[root@k8s-node2 ~]# docker login http://192.168.66.11
Username: admin
Password: 
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
[root@k8s-node2 ~]# docker push 192.168.66.11/project/nginx:test
The push refers to repository [192.168.66.11/project/nginx]
d874fd2bc83b: Preparing 
32ce5f6a5106: Preparing 
f1db227348d0: Preparing 
b8d6e692a25e: Preparing 
e379e8aedd4d: Preparing 
2edcec3590a4: Waiting 
denied: requested access to the resource is denied  #此时是因为在Harbor没有创建project项目所致
#以下为创建项目后的结果
[root@k8s-node2 ~]# docker push 192.168.66.11/project/nginx:test
The push refers to repository [192.168.66.11/project/nginx]
d874fd2bc83b: Pushed 
32ce5f6a5106: Pushed 
f1db227348d0: Pushed 
b8d6e692a25e: Pushed 
e379e8aedd4d: Pushed 
2edcec3590a4: Pushed 
test: digest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3 size: 1570

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值