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

How to build a Private Warehouse by Docker

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the knowledge of "how to build a private warehouse in Docker". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Docker Hub

Currently, Docker officially maintains a public repository, Docker Hub, which already contains more than 15000 images. Most of the requirements can be achieved by downloading the image directly in Docker Hub.

You can sign up for a Docker account at https://hub.docker.com for free.

Enter the execute docker login on the command line, enter the user name and password to log in to Docker Hub, and log in through docker logout.

You can find the image in the official repository through the docker search command, and download the image locally using the docker pull command.

After logging in, users can also push their own images to Docker Hub through the docker push command.

Private warehouse

Sometimes it may not be convenient to use a public repository such as Docker Hub, and users can create their own private repositories.

Docker-registry is an official tool that can be used to build private image repositories.

Install and run docker-registry

It can be run through an official registry image. By default, the warehouse is created in the / var/lib/registry directory.

You can use the-v parameter to place the image file locally in the specified path

Docker run-- name registry-d\-- p 5000 opt/data/registry:/var/lib/registry 5000-- restart=always\-v / opt/data/registry:/var/lib/registry\ registry

Once you have created a private repository, you can use docker tag to mark an image and push it to the repository.

Check the local image first:

Docker image ls

Use docker tag to mark the test-web:latest image as 127.0.0.1:5000/test-web:latest:

Docker tag test-web:latest 127.0.0.1:5000/test-web:latest

Use docker push to upload the image of the tag:

Docker push 127.0.0.1:5000/test-web:latest

Use curl to view images in the repository

Curl 127.0.0.1:5000/v2/_catalog

If you can see {"registry": ["test-web"]}, the image has been uploaded successfully.

Delete the existing image locally, and then try to download the image from the private repository

Docker image rm 127.0.0.1:5000/test-web:latestdocker pull 127.0.0.1:5000/test-web:latest

Note:

If you do not want to use 127.0.0.1Rang5000 as the warehouse address, for example, if you want other hosts in this network segment to push the image to the warehouse, the image will not be successfully pushed when the address of the repository is changed to 192.168.0.101, etc. This is because Docker does not allow images to be pushed in a non-HTTPS way by default. We can remove this restriction through the Docker configuration option.

The / etc/docker/daemon.json file can be modified under centos7 to write the following:

{"registry": ["https://registry.docker-cn.com"]," insecure-registries ": [" 192.168.0.101 Docker 5000 "]} this is the end of the introduction of" how to build a private warehouse ". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report