zoukankan      html  css  js  c++  java
  • 搭建私有仓库Registry(Docker Hub)

    搭建私有仓库Registry(Docker Hub)

    1. 安装Docker

    2. 拉取仓库镜像:# docker pull registry

    3. 生成认证certificate

      mkdir ~/certs
      openssl req -newkey rsa:4096 -nodes -sha256 -keyout /root/certs/domain.key  -x509 -days 365 -out /root/certs/domain.crt
      # 期间输入域名:internal.dockerhub.io
      
    4. 复制认证到docker:

      mkdir /etc/docker/certs.d/internal.dockerhub.io
      cp /root/certs/domain.crt  /etc/docker/certs.d/internal.dockerhub.io/domain.crt
      
    5. 启动仓库镜像

      docker run -d --restart=always --name registry 
      -v /root/docker/registry:/var/lib/registry 
      -v /root/certs:/root/certs 
      -v /root/auth:/root/auth 
      -e REGISTRY_HTTP_ADDR=0.0.0.0:443 
      -e REGISTRY_HTTP_TLS_CERTIFICATE=/root/certs/domain.crt 
      -e REGISTRY_HTTP_TLS_KEY=/root/certs/domain.key 
      -p 443:443 registry
      
      
    6. 修改主机映射

      vi /etc/hosts
      192.168.184.166 mydockerhub.com
      
    7. 创建一个镜像

      docker pull hello-world
      docker tag hello-world internal.dockerhub.io/hello-world
      docker push internal.dockerhub.io/hello-world
      docker rmi internal.dockerhub.io/hello-world
      docker pull internal.dockerhub.io/hello-world
      
      
    8. 使用Rest API查看

      curl -k --tlsv1 https://internal.dockerhub.io/v2/_catalog
      curl -k --tlsv1 -X GET https://internal.dockerhub.io/v2/hello-world/tags/list
      
    9. 添加http basic authentication

      htpasswd -Bbn testuser testpassword > /root/auth/htpasswd
      
    10. 重启

      docker run -d --restart=always --name registry 
      -v /root/docker/registry:/var/lib/registry 
      -v /root/certs:/root/certs 
      -v /root/auth:/root/auth 
      -e "REGISTRY_AUTH=htpasswd" 
      -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" 
      -e "REGISTRY_AUTH_HTPASSWD_PATH=/root/auth/htpasswd" 
      -e REGISTRY_HTTP_ADDR=0.0.0.0:443 
      -e REGISTRY_HTTP_TLS_CERTIFICATE=/root/certs/domain.crt 
      -e REGISTRY_HTTP_TLS_KEY=/root/certs/domain.key 
      -p 443:443 registry
      
      
    11. 登录仓库

      docker login internal.dockerhub.io
      username:testuser
      password:testpassword
      
    12. 保存镜像

      docker save -o registry.tar registry
      docker save -o hello-world.tar hello-world
      
  • 相关阅读:
    HDU4714+三分
    HDU1465+递推
    HDU1437+模拟
    HDU1796+容斥原理
    HDU1432+几何
    Linux---Ls命令 初级实现
    HDU1411+四面体的体积
    HDU1412
    HDU1431+简单题
    请定义一个交通工具(Vehicle)的类,其中有: 属性:速度(speed),体积(size)等等
  • 原文地址:https://www.cnblogs.com/flowerbirds/p/14191790.html
Copyright © 2011-2022 走看看