In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to build Docker private warehouse Registry". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to build Docker private warehouse Registry".
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. However, 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 (details) is provided on Docker hub. We can directly use this registry image to build a container and build our own private repository service. The registry image whose Tag is latest is version 0.9.1, so we directly use version 2.
2. Deployment of Registry
Run the following command to get the registry image
$sudo docker pull registry:2
Then start a container.
$sudo docker run-d-v / wks/registry:/var/lib/registry-p 5000 restart=always-- name registry registry:2
By default, the Registry service will save the uploaded image in the / var/lib/registry of the container. By mounting the / wks/registry directory of the host to this directory, you can save the image to the / wks/registry directory of the host.
Run docker ps to check the container
$sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESf3766397a458 registry:2 "/ bin/registry / etc/d" 46 seconds ago Up 45 seconds 0.0.0.0pur5000-> 5000/tcp registry
It means that we have started the registry service. Open a browser and enter http://127.0.0.1:5000/v2. The following situation indicates that registry is running normally.
3. Verification
Now let's verify it by push the image to registry.
There is an image of hello-world on my machine, and we need to mark it to be pushed to a private warehouse through docker tag.
$sudo docker tag hello-world 127.0.0.1:5000/hello-world
Then view the following local images
$sudo docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEregistry 2 b91f745cd233 5 days ago 220.1 MBubuntu 14.04 a5a467fddcb8 6 days ago 187.9 MBhello-world latest 975b84d108f1 2 weeks ago 960 B127.0.0.1:5000/hello-world latest 975b84d108f1 2 weeks ago 960 B
Next, we run docker push to push the hello-world image into our private repository
$sudo docker push 127.0.0.1:5000/hello-worldThe push refers to a repository [127.0.0.1:5000/hello-world] (len: 1) 975b84d108f1: Image successfully pushed 3f12c794407e: Image successfully pushed latest: digest: sha256:1c7adb1ac65df0bebb40cd4a84533f787148b102684b74cb27a1982967008e4b size: 2744
Now we can check that we have just pushed the hello-world in our local / wks/registry directory. We also enter http://127.0.0.1:5000/v2/_catalog in the browser, as shown in the following figure
Now we can delete our local 127.0.0.1:5000/hello-world and hello-world first.
$sudo docker rmi hello-world$ sudo docker rmi 127.0.0.1:5000/hello-world
Then use docker pull to get the hello-world image from our private repository
$sudo docker pull 127.0.0.1:5000/hello-worldUsing default tag: latestlatest: Pulling from hello-worldb901d36b6f2f: Pull complete 0a6ba66e537a: Pull complete Digest: sha256:1c7adb1ac65df0bebb40cd4a84533f787148b102684b74cb27a1982967008e4bStatus: Downloaded newer image for 127.0.0.1 Ago 220.1 MBubuntu 14.04 a5a467fddcb8 6 days ago 187.9 MB127.0.0.1:5000/hello-world latest 0a6ba66e537a 2 weeks ago 960 B4. Possible problems
There may be a problem that push cannot be mirrored to a private repository. This is because the registry service we started is not secure and reliable. This is where we need to modify the configuration file / etc/default/docker of docker to add the following
DOCKER_OPTS= "--insecure-registry xxx.xxx.xxx.xxx:5000"
Then restart the docker background process
$sudo service docker restart
This is just another push.
The above is all the contents of the article "how to build Docker Private Warehouse Registry". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.