zoukankan      html  css  js  c++  java
  • 使用Harbor搭建docker私服

    搭建私有镜像仓库有几种方式:

    • 官方 registry 推荐使用 registry:2 v2 版本的镜像
    • harbor 方案, 则是在官方的基础上增加了权限控制、界面化等功能

    这里主要说说 harbor 的搭建。

    本机环境:

    centos7
    docker
    docker-compose

    1.Docker 安装

    # yum 包更新
    [root@centos7 ~]# yum update
    
    # 卸载旧版本 Docker
    [root@centos7 ~]# yum remove docker docker-common docker-selinux docker-engine
    
    # 安装软件包
    [root@centos7 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
    
    # 添加 Docker yum源
    [root@centos7 ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    
    # 安装 Docker
    [root@centos7 ~]# yum -y install docker-ce
    
    # 启动 Docker
    [root@centos7 ~]# systemctl start docker
    
    # 查看 Docker 版本号
    [root@centos7 ~]# docker --version
    

    2.Docker Compose 安装(https://github.com/docker/compose/releases

    curl -L https://github.com/docker/compose/releases/download/1.25.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose
    

     

    3、安装Harbor

    采用在线安装方式:下载链接:https://github.com/goharbor/harbor/releases

    $ cd /usr/local
    $ wget https://storage.googleapis.com/harbor-releases/release-1.6.0/harbor-offline-installer-v1.6.3.tgz
    $ tar -zxvf harbor-offline-installer-v1.6.3.tgz
    $ cd harbor
    $ vi harbor.yml
    修改
    hostname =ip
    harbor_admin_password=管理密码(默认是:Harbor12345)
     

    配置完成之后再当前目录下执行./prepare,再执行./install.sh。Harbor就回根据当前目录下的docker-compose.yml下载依赖的镜像

    成功后输出:

    [Step 2]: checking existing instance of Harbor ...
    
    [Step 3]: starting Harbor ...
    Creating network "harbor_harbor" with the default driver
    Creating harbor-log ... done
    Creating harbor-adminserver ... done
    Creating harbor-db          ... done
    Creating registry           ... done
    Creating redis              ... done
    Creating harbor-ui          ... done
    Creating harbor-jobservice  ... done
    Creating nginx              ... done
    
    ✔ ----Harbor has been installed and started successfully.----
    
    Now you should be able to visit the admin portal at https://hub.zhoujiangang.com:41533.
    For more details, please visit https://github.com/goharbor/harbor .
    

      

    执行成功后,你可以访问 ip 来访问管理面板。默认的账号为 admin 密码为 Harbor12345
     

    这里还要在说一个问题
    Harbor是搭建完成了,在我们上传项目的时候可能会出现一些问题

    docker login 192.168.0.103
    Username: aaaa
    Password: 
    Error response from daemon: Get https://192.168.0.103/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
    

      

    这是因为docker1.3.2版本开始默认docker registry使用的是https,我们设置Harbor默认http方式,所以当执行用docker login、pull、push等命令操作非https的docker regsitry的时就会报错。
    解决办法:

    本机连接的话:

    #vim /usr/lib/systemd/system/docker.service  修改如下一行
    ExecStart=/usr/bin/dockerd --insecure-registry=harbor的IP
    远程连接的话:
    在本机配置harbor仓库http可信
    
    /etc/docker/daemon.json中添加“"insecure-registries":["harbor的ip"]”,重启docker
    

      



     
    重启:
    systemctl daemon-reload
    systemctl restart docker.service
    

    重启harbor

    cd harbor目录

    docker-compose up -d

      

  • 相关阅读:
    转: CEF嵌入到单文档mfc
    浅谈C++多态性
    C++面试整理1
    面试汇总
    【转】一些经典的笔试题
    C# 委托
    搭建Nuget
    thinkphp框架之模型(数据库查询)
    利用csc.exe 手动编译C#程序
    css
  • 原文地址:https://www.cnblogs.com/winstonsias/p/12186720.html
Copyright © 2011-2022 走看看