Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Case study on Construction and Interface Management of Docker Private Warehouse

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the construction of Docker private warehouse and interface management cases, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

1. About Registry

The official Docker hub is a good place to manage public images, where we can find the images we want or push our own images.

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 pieces of code on github: the old code base and the new code base. The old code is written in python, and there are performance problems with pull and push. After version 0.9.1, it is marked as deprecated and does not continue development.

From version 2.0 to the development of the new code base, the new code base is written in go language, which modifies the generation algorithm of image id and the preservation structure of image on registry, which greatly optimizes the efficiency of pull and push image.

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

Second, set up Registry

First search and pull the image

Docker search registry # suggests to search first, you can take a look at the relevant images, maybe one day there will be a better image, docker pull registry # tag can not be added, because the latest is v2

Run a registry container

Docker run-d\ # background operation-- name registry-srv\ # specify container name-- restart=always\ # set auto-start-p 5000 opt/zwx-registry:/var/lib/registry 5000\ # port mapping host, and mount the image storage directory locally through the host address access-v / storage\ # Easy to manage and persist-v / opt/zwx-registry/srv-config.yml:/etc/docker/registry/config.yml\ # Mount the configuration file locally, make it easy to modify and save registry

The srv-config.yml content is as follows

The delete parameter of Standard Red is set to true to enable the warehouse to support deletion. This parameter is not available by default, that is, the repository image cannot be deleted.

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

Register for https protocol (otherwise push security authentication will not pass)

You need to download the image through the local repository, all of which need to be configured

Vim / etc/docker/daemon.json # does not have this file by default. You need to add it by yourself. If so, append the following. {"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 # must indicate the address of the warehouse, otherwise you will report an error docker pull xx.xx.xx.xx:5000/nginx

View warehouse image information

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

Third, set up Registry web

First search and pull the image

Docker search docker-registry-webdocker pull hyper/docker-registry-web # this image is used by more people.

Run a registry web container

Docker run-d\ # background operation-- name registry-web\ # specify container name-- restart=always\ # set auto-start-p 8000 restart=always 8080\ # port mapping host, mount the configuration file locally through host address access-v / opt/zwx-registry/web-config.yml:/etc/config.yml\ # to make it easy to modify and save hyper/docker-registry-web

The content of web-config.yml file is as follows

The red readonly parameter is set to false so that the web page can display the delete button. Default is true, read-only status, no delete button, can only be viewed.

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 completed, the browser opens the UI address of the repository to view all application images

Select any applied image library to view all the tag information of the image. Each tag is followed by a delete button (not available by default. Refer to config.yml for configuration).

IV. Quick deployment

Cluster mode allows rapid deployment of registry and registry web through docker stack.

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

Docker stack deploy-c docker-compose.yml RGTversion: '3.7' # docker stack needs to be version 3.0 or later: services: registry-srv: # Service name image: registry ports: # Mapping port-5000 volumes: # Mount image path and configuration file Note that the modified path is the same as 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 name image: hyper/docker-registry-web ports: # Mapping port-8000 placement 8080 volumes: # mount configuration file Note that the modification path is the same as 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 up a single task, and constrain the master node to run mode: replicated replicas: 1 placement: constraints:-node.role = = manager Thank you for reading this article carefully I hope the article "the case of Building and Interface Management of Docker Private Warehouse" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report