In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
What the editor wants to share with you this time is how to achieve Registry deployment in Docker private warehouse. The article is rich in content. Interested friends can learn about it. I hope you can get something after reading this article.
As docker uses more and more images, you need to have a place to keep the images, which is the repository. At present, there are two commonly used warehouses: public warehouse and private warehouse. The most convenient thing is to use the public warehouse to upload and download. You don't need to register to download the image of the public warehouse, but you need to register when uploading.
Registry and Harbor are the most commonly used private repositories, so how to build registry private repositories is described in detail. Harbor will be deployed in the next blog post.
First, deploy Registry private warehouse
Case description
Two CentOS7.4, one for Docker private warehouse and the other for Docker client.
Both servers need to install the Docker service, please refer to the blog post: install the Docker.v19 version
1. Configure registry private warehouse
[root@centos01 ~] # echo "net.ipv4.ip_forward = 1" > > / etc/sysctl.conf [root@centos01 ~] # sysctl-p net.ipv4.ip_forward = 1 [root@centos01 ~] # vim / etc/docker/daemon.json {"registry-mirrors": ["https://6kx4zyno.mirror.aliyuncs.com"]} [root@centos01 ~] # systemctl reload docker [root@centos01 ~] # docker search registry [root@centos01] # docker run-d -name registry-- restart=always-v / opt/registry:/var/lib/registry registry [root@centos01 ~] # docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESa7773d77b8a3 registry "/ entrypoint.sh / etc …" 50 seconds ago Up 46 seconds 0.0.0.0 5000/tcp registry 5000-> 5000/tcp registry [root@centos01 ~] # docker images REPOSITORY TAG IMAGE ID CREATED SIZEregistry latest 708bc6af7e5e 3 months ago 25.8MBtomcat latest 1b6b1fe7261e 5 days ago 647MBhub.c.163.com/public/centos 6.7-tools b2ab0ed558bb 3 years ago 602MB [root@centos01 ~] # vim / etc / docker/daemon.json {"registry-mirrors": ["https://6kx4zyno.mirror.aliyuncs.com"]," "insecure-registries": ["192.168.100.10 systemctl reload docker 5000"]} [root@centos01 ~] # systemctl reload docker
2. Upload the image to the registry private repository
[root@centos01 ~] # docker tag hub.c.163.com/public/centos:6.7-tools 192.168.100.10:5000/image/centos:6.7 [root@centos01 ~] # docker push 192.168.100.10:5000/image/centos:6.7
Configure the Docker client to access the private warehouse
[root@centos02 ~] # vim / etc/docker/daemon.json {"registry-mirrors": ["https://6kx4zyno.mirror.aliyuncs.com"], "insecure-registries": ["192.168.100.10 insecure-registries 5000"]} [root@centos02 ~] # systemctl restart docker [root@centos02 ~] # docker pull 192.168.100.10:5000/image/centos:6.7 [root@centos02 ~] # docker images REPOSITORY TAG IMAGE ID CREATED SIZE192.168.100.10:5000/image/centos 6.7 b2ab0ed558bb 3 years ago 602MB
At this point, the registry private warehouse has been built, but now there is a problem. If this is also deployed, all personnel within the enterprise can access our private warehouse. For security, add an authentication for registry. Only after passing the authentication can you upload or download images in the private warehouse.
Configure registry to load authentication
[root@centos01 ~] # yum-y install httpd-tools [root@centos01 ~] # mkdir / opt/registry-auth [root@centos01 ~] # htpasswd-Bbn bob pwd@123 > / opt/registry-auth/htpasswd [root@centos01 ~] # docker run-d-p 5000 docker run-d-p 5000-- restart=always\-v / opt/registry-auth/:/auth/\-v / opt/registry:/var/lib/registry-- name registry-auth-e "REGISTRY_AUTH=htpasswd"\-e REGISTRY_ AUTH_HTPASSWD_REALM=Registry Realm "\-e" REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd "registry [root@centos01 ~] # docker tag tomcat:latest 192.168.100.10:5000/image/tomcat:1.0 [root@centos01 ~] # docker push 192.168.100.10:5000/image/tomcat:1.0 no basic auth credentials [root@centos01 ~] # docker login 192.168.100.10 root@centos01 5000 Username: bob Password:... Login Succeeded [root@centos01 ~] # docker push 192.168.100.10:5000/image/tomcat:1.0 The push refers to repository [192.168.100.10:5000/image/tomcat] b0ac242ce8d3: Pushed5e71d8e4cd3d: Pushedeb4497d7dab7: Pushedbfbfe00b44fc: Pushedd39111fb2602: Pushed155d997ed77c: Pushed88cfc2fcd059: Pushed760e8d95cf58: Pushed7cc1c2d7e744: Pushed8c02234b8605: Pushed1.0: digest: sha256:55b41e0290d32d6888aee2e9a15f03cc88d2f49d5ad68892c54b9527d0ed181c size: 2421 [root@centos02 ~] # docker pull 192.168.100.10:5000/image/tomcat:1.0 Error response from daemon: Get http://192. 168.100.10:5000/v2/image/tomcat/manifests/1.0: no basic auth credentials [root@centos02 ~] # docker login 192.168.100.10 docker login 5000 Username: bob Password: Login Succeeded [root@centos02 ~] # docker pull 192.168.100.10:5000/image/tomcat:1.0 1.0: Pulling from image/tomcat376057ac6fa1: Pull complete5a63a0a859d8: Pull complete496548a8c952: Pull complete2adae3950d4d: Pull complete0a297eafb9ac: Pull complete09a4142c5c9d: Pull complete9e78d9befa39: Pull complete18f492f90b9c: Pull complete7834493ec6cd: Pull complete216b2be21722: Pull completeDigest: Sha256:55b41e0290d32d6888aee2e9a15f03cc88d2f49d5ad68892c54b9527d0ed181cStatus: Downloaded newer image for 192.168.100.10:5000/image/tomcat:1.0192.168.100.10:5000/image/tomcat:1.0 [root@centos02 ~] # docker images REPOSITORY TAG IMAGE ID CREATED SIZE192.168.100.10:5000/image/tomcat 1.0 1b6b1fe7261e 5 days ago 647MB192.168.100.10:5000/image/centos 6.7 b2ab0ed558bb 3 Years ago 602MB finished reading this article on how the Docker private repository implements Registry deployment. If you think the content of the article is good, you can share it with more people.
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.