美文网首页
docker企业级镜像仓库harbor(vmware 中国团队)

docker企业级镜像仓库harbor(vmware 中国团队)

作者: zwb_jianshu | 来源:发表于2019-07-25 16:14 被阅读0次

    第一步:安装docker和docker-compose

    rm -fr /etc/yum.repos.d/local.repo
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
    sed -i 's#download.docker.com#mirrors.tuna.tsinghua.edu.cn/docker-ce#g' /etc/yum.repos.d/docker-ce.repo
    yum install docker-ce docker-compose -y
    

    第二步:下载harbor-offline-installer-v1.3.0.tgz

    wget http://192.168.12.201/docker_image/harbor-offline-installer-v1.8.0.tgz
    

    第三步:上传到/opt,并解压

    cd /opt
    tar xf harbor-offline-installer-v1.8.0.tgz
    cd harbor 
    

    第四步:修改harbor.cfg配置文件

    vim harbor.yml
    hostname = 10.0.0.11
    harbor_admin_password = 123456
    

    第五步:执行install.sh

    [root@docker01 harbor]# ./install.sh 
    Creating harbor-jobservice ... done
    Creating nginx ... done
    Creating harbor-db ... 
    Creating redis ... 
    Creating registryctl ... 
    Creating registry ... 
    Creating harbor-core ... 
    Creating harbor-portal ... 
    Creating harbor-jobservice ... 
    Creating nginx ... 
    ✔ ----Harbor has been installed and started successfully.----
    Now you should be able to visit the admin portal at http://10.0.0.11. 
    For more details, please visit https://github.com/goharbor/harbor .
    

    第六步:浏览器登录

    用户:admin
    密码:123456
    
    image.png

    第七步:测试上传下载镜像(docker02上)

    vim /etc/docker/daemon.json
    {
    "registry-mirrors": ["https://registry.docker-cn.com"] ,
      "insecure-registries": ["10.0.0.11"],
      "hosts":["tcp://0.0.0.0:2376","unix:///var/run/docker.sock"],
      "cluster-store": "consul://10.0.0.13:8500",
      "cluster-advertise": "10.0.0.12:2376"
    }
    [root@docker02 ~]# systemctl restart docker
    [root@docker02 ~]# docker login 10.0.0.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@docker02 ~]# docker images 
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    busybox             latest              d8233ab899d4        5 months ago        1.2MB
    centos              6.9                 adf829198a7f        11 months ago       195MB
    [root@docker02 ~]# docker tag centos:6.9 10.0.0.11/library/centos:6.9
    上传镜像:
    [root@docker02 ~]# docker push 10.0.0.11/library/centos:6.9
    The push refers to repository [10.0.0.11/library/centos]
    b5e11aae8a8e: Pushed 
    6.9: digest: sha256:0e59afcc4d7a07fcbd6285f79f6f377ce997ae091c10f8e3c2feb2bcda90b06c size: 529
    下载镜像:
    [root@docker02 ~]# docker pull 10.0.0.11/library/centos:6.9
    6.9: Pulling from library/centos
    Digest: sha256:0e59afcc4d7a07fcbd6285f79f6f377ce997ae091c10f8e3c2feb2bcda90b06c
    Status: Image is up to date for 10.0.0.11/library/centos:6.9
    10.0.0.11/library/centos:6.9
    [root@docker02 ~]# ls
    docker_centos6.9.tar.gz  harbor-offline-installer-v1.8.0.tgz  
    

    第八步:刷新浏览器查看

    image.png

    到此测试上传下载镜像完成!

    第九步:设置https仓库访问协议

    申请自己的域名证书
    例如:
    域名:blog.*.com.cn
    证书:blog.*.com.cn.zip
    wget  http://192.168.12.201/docker_image/blog.*.com.cn.zip
    上传到/opt/harbor/cert下解压
    [root@docker01 cert]# unzip   blog.*.com.cn.zip
    [root@docker01 cert]# cd Nginx
    [root@docker01 cert]# pwd
    /opt/harbor/cert
    [root@docker01 cert]# ls
    1_blog.*.com.cn_bundle.crt  2_blog.*.com.cn.key
    [root@docker01 harbor]# vim harbor.yml
    hostname: blog.*.com.cn
    https:
      port: 443
      certificate: /opt/harbor/cert/Nginx/1_blog.*.com.cn_bundle.crt
      private_key: /opt/harbor/cert/Nginx/2_blog.*.com.cn.key
    [root@docker01 harbor]# ./install.sh
    [Step 3]: starting Harbor ...
    Creating harbor-portal ... done
    Creating nginx ... done
    Creating harbor-db ... 
    Creating redis ... 
    Creating registry ... 
    Creating registryctl ... 
    Creating harbor-core ... 
    Creating harbor-portal ... 
    Creating harbor-jobservice ... 
    Creating nginx ... 
    ✔ ----Harbor has been installed and started successfully.----
    Now you should be able to visit the admin portal at https://blog.*.com.cn. 
    For more details, please visit https://github.com/goharbor/harbor .
    登录仓库:
    [root@docker01 harbor]# docker login blog.*.com.cn
    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 harbor]# docker tag wordpress:latest blog.qstack.com.cn/zwb-test/wordpress:latest
    推送镜像:
    [root@docker01 harbor]# docker push blog.qstack.com.cn/zwb-test/wordpress:latest
    2ec5c0a4cb57: Pushed 
    latest: digest: sha256:3b1f4e2289e77d10afa51918be3f66dccfa536a4d53b49d8a1466fe6cb225e28 size: 4287
    

    第十步:用域名登录浏览器测试查看

    image.png

    到此https镜像上传测试成功!

    相关文章

      网友评论

          本文标题:docker企业级镜像仓库harbor(vmware 中国团队)

          本文链接:https://www.haomeiwen.com/subject/vhihrctx.html