Detailed explanation of the construction and interface management of Docker private warehouse

Detailed explanation of the construction and interface management of Docker private warehouse

1. About Registry

The official Docker hub is a good place to manage public images. We can find the images we want on it and push our own images up.

But sometimes our usage scenarios require us to have a private image repository to manage our own images. This can be achieved through the open source software Registry.

Registry has two codes on GitHub: the old code base and the new code base. The old code is written in Python and has performance issues with pull and push. After version 0.9.1, it was marked as deprecated and is no longer developed.

Starting from version 2.0, development has started in a new code base, which is written in the Go language. The image ID generation algorithm and the image storage structure on the registry have been modified, greatly optimizing the efficiency of pulling and pushing images.

The official registry image is provided on the Docker hub. We can directly use the registry image to build a container and build our own private warehouse service.

2. Build Registry

First search and pull the image

docker search registry # It is recommended to search first, you can look at the related images, maybe there will be better images someday docker pull registry # You don’t need to add a tag, because the latest one is v2

Running a registry container

docker run -d \ # Run in the background --name registry-srv \ # Specify the container name --restart=always \ # Set automatic startup -p 5000:5000 \ # Port mapping host, access through the host address -v /opt/zwx-registry:/var/lib/registry \ # Mount the image storage directory locally for easy management and persistence -v /opt/zwx-registry/srv-config.yml:/etc/docker/registry/config.yml \ # Mount the configuration file locally to facilitate modification and saving of registry

The content of srv-config.yml is as follows

The delete parameter marked in red is set to true to enable the warehouse to support the deletion function. This parameter is not available by default, which means that the repository image cannot be deleted.

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

Register the https protocol (otherwise push security authentication will fail)

You need to download the image through the local warehouse, and you need to configure

vim /etc/docker/daemon.json # This file does not exist by default, you need to add it yourself. If it exists, append the following content.
{ "insecure-registries":["xx.xx.xx.xx:5000"] } # Specify IP address or domain name systemctl daemon-reload # Daemon restart systemctl restart docker # Restart Docker service

Image upload and download

docker push xx.xx.xx.xx:5000/nginx # Be sure to specify the warehouse address, otherwise an error will be reported docker pull xx.xx.xx.xx:5000/nginx

View warehouse mirror information

curl -XGET http://xx.xx.xx.xx:5000/v2/_catalog # View the repository image list (you can also open it through a windows browser)
curl -XGET http://xx.xx.xx.xx:5000/v2/image_name/tags/list # View the specified application image tag

3. Build Registry web

First search and pull the image

docker search docker-registry-web
docker pull hyper/docker-registry-web # This image is used by many people

Run a registry web container

docker run -d \ # Run in the background --name registry-web \ # Specify the container name --restart=always \ # Set automatic startup -p 8000:8080 \ # Port mapping host, access through the host address -v /opt/zwx-registry/web-config.yml:/etc/config.yml \ # Mount the configuration file locally for easy modification and saving hyper/docker-registry-web

The contents of the web-config.yml file are as follows

The red readonly parameter is set to false so that the web page can display a delete button. The default is true, read-only state, no delete button, only viewing.

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, you can view all application images by opening the repository UI address in the browser.


Select any application image library to view all tag information of the image. There is a delete button after each tag (no by default, refer to config.yml for configuration)

4. Quick deployment

In cluster mode, you can quickly deploy registry and registry web through docker stack.

Create new configuration files srv-config.yml and web-config.yml and put them in the specified path, then create a new docker-compose.yml file and execute the command.

docker stack deploy -c docker-compose.yml RGT
version: '3.7' # docker stack needs to be version 3.0 or above services:
 registry-srv: # Service nameimage: registry
 
 ports: #Mapped port - 5000:5000
  
 volumes: # Mount the image path and configuration file. Note that the modified path should be consistent with the actual one - /opt/zwx-registry:/var/lib/registry
  - /opt/zwx-registry/srv-config.yml:/etc/docker/registry/config.yml
  
 deploy: # Set a single task and constrain the master node to run mode: replicated
  replicas: 1
  placement:
  constraints:
   - node.role == manager
  
 registry-web: #Service nameimage: hyper/docker-registry-web
 
 ports: # Mapped ports - 8000:8080
 
 volumes: #Mount the configuration file. Note that the modified path should be consistent with the actual one - /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 constrain the master node to run mode: replicated
  replicas: 1
  placement:
  constraints:
   - node.role == manager

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • Detailed steps to build a Docker Registry private warehouse
  • Detailed steps for Docker to build a local private warehouse
  • Docker private repository management and deletion of images in local repositories
  • How to query or obtain images in a private registry
  • Docker tutorial: Private warehouse detailed explanation
  • Example of how to upload a Docker image to a private repository
  • Detailed explanation of centos7 docker1.12 installation of private warehouse
  • Detailed explanation of the easiest way to build a Docker private warehouse
  • Detailed explanation of the construction and use of Docker private warehouse
  • Detailed explanation of CentOS 7: Docker private warehouse construction and use

<<:  MySQL deadlock routine: inconsistent batch insertion order under unique index

>>:  WeChat applet to achieve automatic video playback imitating GIF animation effect example

Recommend

Install Percona Server+MySQL on CentOS 7

1. Environmental Description (1) CentOS-7-x86_64,...

25 Examples of News-Style Website Design

bmi Voyager Pitchfork Ulster Grocer Chow True/Sla...

Detailed explanation of JavaScript primitive data type Symbol

Table of contents Introduction Description Naming...

Implementation of CSS Fantastic Border Animation Effect

Today I was browsing the blog site - shoptalkshow...

17 excellent web designs carefully crafted by startups

Startups often bring us surprises with their unco...

Detailed tutorial on installing MYSQL under WINDOWS

1. Download the installation package -Choose the ...

Example code for implementing simple ListViews effect in html

HTML to achieve simple ListViews effect Result: c...

How to install common components (mysql, redis) in Docker

Docker installs mysql docker search mysql Search ...

Best way to replace the key in json object

JSON (JavaScript Object Notation, JS Object Notat...

In-depth analysis of the Linux kernel macro container_of

1. As mentioned above I saw this macro when I was...

Detailed explanation of how to access MySQL database remotely through Workbench

Preface Workbench is installed on one computer, a...

CSS3 achieves infinite scrolling/carousel effect of list

Effect Preview Ideas Scroll the current list to t...

Install Apple Mac OS X in VMWare12 Graphic Tutorial

1. Introduction: Because my friend wanted to lear...

Solution to find all child rows for a given parent row in MySQL

Preface Note: The test database version is MySQL ...

Example of how to implement underline effects using Css and JS

This article mainly describes two kinds of underl...