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

Hadoop 2.x vs 3.x 22-point comparison, Hadoop 3.x improvements over 2.x

Question Guide 1. How does Hadoop 3.x tolerate fa...

Detailed explanation of the use of vue-resource interceptors

Preface Interceptor In some modern front-end fram...

Beginner's guide to building a website ⑥: Detailed usage of FlashFXP

Today I will introduce the most basic functions of...

How to install Docker CE on Ubuntu 18.04 (Community Edition)

Uninstall old versions If you have installed an o...

How to modify Ubuntu's source list (source list) detailed explanation

Introduction The default source of Ubuntu is not ...

Discussion on CSS style priority and cascading order

In general : [1 important flag] > [4 special fl...

mysql 8.0.15 winx64 decompression version graphic installation tutorial

Every time after installing the system, I have to...

The scroll bar position is retained when scrolling the vant list component

The scroll bar position is retained when scrollin...

Detailed explanation of hosts file configuration on Linux server

Linux server hosts file configuration The hosts f...

Analysis of the Docker deployment Consul configuration process

Execute Command docker run -d --name consul -p 85...

Three ways to forward linux ssh port

ssh is one of the two command line tools I use mo...

MYSQL stored procedures, that is, a summary of common logical knowledge points

Mysql stored procedure 1. Create stored procedure...

Example code for hiding element scrollbars using CSS

How can I hide the scrollbars while still being a...

Vue implements time countdown function

This article example shares the specific code of ...

Use of MySQL official export tool mysqlpump

Table of contents Introduction Instructions Actua...