Harbor镜像仓库搭建

Harbor镜像仓库搭建(测试环境centos7)

 

一、Harbor硬件和软件要求

harbor软件环境需要docker和docker-compose,具体版本要求以及设备硬件要求见官网

https://goharbor.io/docs/1.10/install-config/installation-prereqs/

二、 Harbor服务器搭建

1. 下载harbor

版本下载地址:https://github.com/goharbor/harbor/releases

  • 离线版本安装:offline

  • 在线版本安装:online

这里选择离线版本测试安装: `wget https://github.com/goharbor/harbor/releases/download/v1.10.1/harbor-offline-installer-v1.10.1.tgz

2. 解压安装文件并配置harbor.yml文件

tar -zxf harbor-offline-installer-v1.10.1.tgz

编辑harbor配置文件 harbor.yml,以下是主要参数:

hostname: 10.0.0.130 #服务器IP或域名
http:
port: 9001 #默认是80端口
harbor_admin_password: Harbor12345  #Harbor超级管理员密码
database:
password: root123  #数据库管理员密码

data_volume: /data   #配置harbor数据文件,也就是未来镜像文件的存储位置(这个应该是可以挂载到硬盘,就是下午说得500G硬盘)

把https注释

## https related config
#https:
# # https port for harbor, default is 443
# port: 443
# # The path of cert and key files for nginx
# certificate: /your/certificate/path
# private_key: /your/private/key/path

3. 启动安装Harbor

修改完配置文件后,在当前目录执行./install.sh,harbor服务器会自动调用docker-compose分析依赖的镜像并逐个下载,同时自动安装并启动各服务

./install.sh

[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registry     ... done
Creating harbor-portal ... done
Creating redis         ... done
Creating harbor-db     ... done
Creating registryctl   ... done
Creating harbor-core   ... done
Creating nginx             ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----

安装成功!

4. web登录

http://ip:port

username: admin

password: Harbor12345

5. 服务器登录

这里使用的是http,做一些修改

这里需要在客户端机器上修改docker的配置

1. 修改docker的拉取信任vi /etc/docker/daemon.json

vim /etc/docker/daemon.json

#---------# insecure-registries的添加内容
{
 "registry-mirrors": ["http://hub-mirror.c.163.com"],
 "insecure-registries": ["x.x.x.x"] # 比如ip为10.0.0.129
}

保存

2. 重启docker服务

systemctl daemon-reload systemctl restart docker

3. 登录harbor
[root@chow home]# docker login 10.0.0.130:9001
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

4. 推送镜像

测试推送,查看镜像 docker images

REPOSITORY  TAG     IMAGE ID       CREATED      SIZE
ubuntu     latest 4e5021d210f6   3 weeks ago  64.2MB

假设登录web端,创建一个新项目 vmcmdi,把一个ubuntu镜像推送到harbor上得vmcmdi项目下,需要对镜像处理

  1. 标记镜像(重新打tag)

    docker tag ubuntu:latest 10.0.0.130:9001/vmcmdi/ubuntu:latest

  2. 推送镜像

    docker push 10.0.0.130:9001/vmcmdi/ubuntu:latest

  3. 拉取镜像

    docker pull 10.0.0.130:9001/vmcmdi/ubuntu:latest

     

posted @ 2020-05-16 09:39  静静别跑  阅读(433)  评论(0编辑  收藏  举报