181. docker企业级镜像仓库harbor

1. 安装harbor

1. 安装docker和docker-compose
[root@docker02 ~]# yum install docker-compose -y

2. 下载harbor-offline-installer-v1.5.1.tgz

3. 上传到/opt,并解压
[root@docker02 opt]# tar xf harbor-offline-installer-v1.8.0.tgz 

4. 修改harbor.yml配置文件
[root@docker02 harbor]# vim harbor.yml
 hostname = 10.0.0.12    //本机的ip
 harbor_admin_password = 123456

5. 执行install.sh
./install.sh

2. 访问harbor

访问:http://10.0.0.12
用户名:admin
密码:123456

在这里插入图片描述

3. docker01推送镜像

1. 配置仓库地址
[root@docker01 ~]# vim /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://registry.docker-cn.com"],
  "insecure-registries": ["10.0.0.12"]
}

2. 重启docker
systemctl restart docker

3. 打tag标签--->登录 docker login 10.0.0.12
[root@docker01 ~]# docker tag alpine:cheng 10.0.0.12/library/alpine:cheng
[root@docker01 ~]# docker login 10.0.0.12
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@docker01 ~]# docker push 10.0.0.12/library/alpine:cheng
The push refers to repository [10.0.0.12/library/alpine]
13d210bd1991: Pushed 
cheng: digest: sha256:ceee4048a8b98b7a9ea20217559e3885257f02eef502011cbac0cd7c5237b9d6 size: 528

在这里插入图片描述

4. harbor配置https

1. 准备域名证书
[root@docker02 harbor]# vim harbor.yml 
hostname: yinwucheng.com

# http related config
#http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
#  port: 80

# https related config
https:
#   # https port for harbor, default is 443
  port: 443
#   # The path of cert and key files for nginx
  certificate: /opt/cert/2859604_www.yinwucheng.com.pem
  private_key: /opt/cert/2859604_www.yinwucheng.com.key


2. 需要重新安装
将脚本中的load注释--->执行脚本./install.sh
#docker load -i ./harbor*.tar.gz

windows 做域名解析 即可登录dashboard
pull的话需要在服务器做域名解析
[root@docker02 ~]# docker pull yinwucheng.com/library/alpine:cheng
cheng: Pulling from library/alpine
c8ab8c57353c: Pull complete 
Digest: sha256:ceee4048a8b98b7a9ea20217559e3885257f02eef502011cbac0cd7c5237b9d6
Status: Downloaded newer image for yinwucheng.com/library/alpine:cheng
yinwucheng.com/library/alpine:cheng

5. docker-registry迁移至harbor

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

新建项目--->新建仓库--->选择提供者--->目标URL:http://10.0.0.11:5000-->测试连接
docker run -d -p 5000:5000 --restart=always --name registry -v /opt/myregistry:/var/lib/registry registry

将docker-registry迁移至harbor
配置同步规则--->目的Namespace【项目的名称】--->同步---
发布了184 篇原创文章 · 获赞 72 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/chengyinwu/article/details/104080228