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 Docker Private Warehouse

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article focuses on "how to build a private Docker warehouse", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to build a Docker private warehouse.

1. Docker Hub1.1. Register and log in

Sign up for a Docker account at https://hub.docker.com/ for free.

Enter the user name and password at the command line docker login to complete logging in to Docker Hub from the command line interface.

You can log in through docker logout.

1.2. Pull the image

You can use the docker search command to find the image in the official repository and use the docker pull command to download it locally.

Docker search tomcatdocker pull tomcat

1.3. Push image

You can use the docker push command to push your image to Docker Hub after logging in.

Docker tag / hello-world:latest

two。 Private warehouse 2.1. Install and run docker-registry

You can run it by obtaining an official registry image. By default, the repository is created in the container's / var/lib/registry directory.

You can use the-v parameter to store the image file to the specified path locally.

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

2.2. Upload, search and download images on private repositories

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

Check the images that already exist on this machine:

Docker image ls

Use docker tag to mark the test-web:latest image as 127.0.0.1:5000/test-web:latest. The format is docker tag IMAGE [: TAG] [REGISTRY_HOST [: REGISTRY_PORT] /] REPOSITORY [: TAG]

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 {"repositories": ["test-web"]}, the image has been uploaded successfully.

Delete the existing image, 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

2.3. Matters needing attention

If you don't want to use 127.0.0.1 Grou5000 as the repository address, for example, you want other hosts in this network segment to push images to private repositories. You will have to use an intranet address such as 192.168.100.100purl 5000 as a private repository address, and you will find that the image cannot be pushed successfully.

Because Docker does not allow images to be pushed in a non-HTTPS way by default. We can remove this restriction through the configuration option of Docker.

Ubuntu 16.04 +, Debian 8 +, centos 7

For systems using systemd, you can write the following in / etc/docker/daemon.json (if the file does not exist, create it).

{"registry-mirror": ["https://registry.docker-cn.com"]," insecure-registries ": [" 192.168.100.100Suzhou 5000 "]}

Windows 、 Mac

For Docker for Windows and Docker for Mac, edit daemon.json in the settings and add the same string as above.

At this point, I believe you have a deeper understanding of "how to build a private Docker warehouse". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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

Internet Technology

Wechat

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

12
Report