Docker private warehouse building and Interface Management

 


I, on the Registry

The official Docker hub is a good place for managing the public image, we can find the image we want on it, you can also push up our own image.

But sometimes we use scenario we need to have a private warehouse mirror for managing our own image. This purpose can be achieved by open source software Registry.

 Registry There are two code on github: old code base and new code base. Old code that is written using python, there is a pull and push performance issues, then out to the 0.9.1 version are marked as deprecated, no longer continue to develop.

 It is to be from the start of the new version 2.0 code base development, new code base is written using go, modifies image id generation algorithm, registry stored on mirrored structure, greatly improving the efficiency of pull and push mirroring.

 The official registry of the image on Docker hub, we can directly use the registry to construct a mirror container, to build our own private warehouses.

 


Second, build Registry

First, search for and pull the mirror

Search Registry Docker    # recommended that you search, you can look at the relevant mirror, maybe someday have a better image of the 
Docker pull Registry     # label can not add, because the current is the latest v2

 

 

  Run a registry container

RUN -d Docker \             # run in the background 
--name Registry-SRV \     # specified container name 
--restart = Always \         # set to automatically start 
-p 5000: 5000 \             # port mapping host, accessed by the host address 
-v / opt / ZWX-Registry: / var / lib / Registry \      # the mirror mounts to the local storage directory, easy to manage and persistence 
-v /opt/zwx-registry/srv-config.yml:/etc/docker/registry/config .yml \     # the mount configuration files to a local, easy to modify and save 
registry

 

  srv-config.yml follows

  Marked red delete parameter set to true, is to allow the warehouse to support delete function. Without this default parameter, which is the mirror image can not be deleted warehouse.

version: 0.1
log:
  fields:
    service: registry
storage:
  delete:
    enabled: true
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/registry
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3

  Registration https protocol (otherwise push hard on safety certification)

  Required by local repository download the image, all you need to configure  

/etc/docker/daemon.json vim        # default is no such file, add their own, there is the additional following. 
{ " In the insecure-Registries " : [ " xx.xx.xx.xx: 5000 " ]}  # specify the IP address or domain name 
systemctl daemon -reload # daemon restart systemctl docker restart # restart docker Service

Mirror upload and download

the Push xx.xx.xx.xx Docker: 5000 / nginx             # must indicate the address of the warehouse, otherwise it will error 
docker pull xx.xx.xx.xx: 5000 / nginx

 

  View Mirror Information Warehouse

-XGET HTTP curl: //xx.xx.xx.xx: 5000 / v2 / _catalog     # View warehouse mirror list (also open to view through the windows browser) 
curl -XGET HTTP: //xx.xx.xx.xx: 5000 / v2 / image_name / Tags / List  # View application image tag specified

 

 

 


Third, build Registry web

First, search for and pull the mirror

docker search docker-registry-web
Hyper pull Docker / Docker-Registry Web-    # this image with more people

 

 

  Run a registry web container

RUN -d Docker \             # run in the background 
--name-Registry Web \     # specified container name 
--restart = Always \         # set to automatically start 
-p 8000: 8080 \             # port mapping host, accessed by the host address 
-v / opt /zwx-registry/web-config.yml:/etc/config.yml \     # the mount configuration files to a local, easy to modify and save 
hyper / docker-registry-web

 

 

  web-config.yml document reads as follows

Marked red readonly parameter set to false, in order to web page may delete button. The default is true, read-only, no delete button, can only view.

registry:
  # Docker registry url
  url: http://10.88.77.32:5000/v2
  # Docker registry fqdn
  name: localhost:5000
  # To allow image delete, should be false
  readonly: false
  auth:
    # Disable authentication
    enabled: false

After the deployment is complete, open the repository browser UI to see to address all application image

Select any application image gallery to see all the tag information of the mirror, behind each tag has a delete button (not the default configuration reference config.yml)

 

 

 


Fourth, fast deployment

  Cluster mode can quickly deploy registry and registry web by docker stack.

  New profile srv-config.yml, web-config.yml into the designated path, then the new docker-compose.yml file, execute command.

docker stack deploy -c docker-compose.yml RGT

 

Version: '3.7 '      # Docker Stack 3.0 or later is required
services:
  Registry - SRV:      # service name
    image: registry
    
    the ports:         # mapping port
       --5000: 5000
      
    Volumes:        # configuration file path and mount the mirror, change the path consistent with the actual note
       - / opt / ZWX-Registry: / var / lib / Registry
       - /opt/zwx-registry/srv-config.yml:/etc/docker/ Registry / config.yml
      
    Deploy:        # Set a single task, and the main constraint nodes running
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      
  Registry - Web:      # service name   
    Image: Hyper / Docker-registry- Web
    
    the ports:        # mapping port
       --8000: 8080
    
    Volumes:      # mount configuration file, pay attention to modify the path consistent with the actual
       - /opt/zwx-registry/web-config.yml:/conf/ config.yml
      
    environment:
      - REGISTRY_URL=http://registry-srv:5000/v2
      - REGISTRY_NAME=localhost:5000
    
    Deploy:        # Set a single task, and the main constraint nodes running
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager

 

 


 

 Author: Leozhang GG

Source:  https://www.cnblogs.com/leozhanggg/p/12050322.html

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。

Guess you like

Origin www.cnblogs.com/leozhanggg/p/12050322.html