In CentOS 7.X, Docker builds a local repository registry and reports an error.

Source: Internet
Author: User
Tags ldap centos docker hub docker run docker registry

Downloading images from docker hub is slow, and your internal images generally require high speed and security. Therefore, you can build a local repository registry. The following describes the next steps.
Environment: centos 7.2
1. Install docker
Yum install docker-y
Systemctl start docker. service
Systemctl enable docker. service

2. Build a warehouse
Download registry
Docker search registry

[Root @ docker5 registry] # docker search registry
Index name description stars official automatic
Docker. io docker. io/registry Containerized docker registry 894 [OK]
Docker. io docker. io/konradkleine/docker-registry-frontend Browse and modify your Docker registry in... 99 [OK]
Docker. io docker. io/atcol/docker-registry-ui A web UI for easy private/local Docker Reg... 79 [OK]
Docker. io docker. io/distribution/registry WARNING: NOT the registry official image !!... 38 [OK]
Docker. io docker. io/samalba/docker-registry 36 [OK]
Docker. io docker. io/hyper/docker-registry-web Web UI for private docker registry v2. 28 [OK]
Docker. io docker. io/marvambass/nginx-registry-proxy Docker Registry Reverse Proxy with Basic A... 27 [OK]
Docker. io docker. io/h3nrik/registry-ldap-auth LDAP and Active Directory authentication p... 12 [OK]
Docker. io docker. io/jhipster-registry JHipster Registry, based on Netflix Eureka... 6 [OK]
[Root @ docker5 registry] # docker pull docker. io/registry
Wait until the download is complete.
Build a repository:

Docker run-d-p 5000: 5000-v/home/registry:/tmp/registry
By default, docker stores the repository in the/tmp/registry Directory of the container. You can use the-v parameter to save the image file to the specified path.
Check whether the task is running:

[Root @ docker5 registry] # netstat-tunlp | grep 5000
Tcp6 0 0: 5000: * LISTEN 3791/docker-proxy
Change a tag:

Docker tag mysql: latest 192.168.2.75: 5000/mysql20160615
Upload the test image to the local repository:

Docker push 192.168.2.75: 5000/mysql20160615
If an https file has been created, the operation is successful. If the file is http, an error is returned. The reason is that Docker uses https by default after 1.3.X. Therefore, when you use the docker pull command to download a remote image, the preceding error is reported if the remote docker registry is not https. Solution:
Vi/etc/sysconfig/docker

OPTIONS = '-- selinux-enabled -- insecure-registry 192.168.2.75: 100', where -- insecure-registry 192.168.2.75: 5000 is added by yourself.
Restart docker and the corresponding container after setting, and then push again.

[Root @ docker5 registry] # docker push 192.168.2.75: 5000/testimage
The push refers to a repository [192.168.2.75: 5000/testimage] (len: 1)
Sending image list
Pushing repository 192.168.2.75: 5000/testimage (1 tags)
Limit 474eb5b4: Image successfully pushed
B48a20c39b28: Image successfully pushed
C79ebe41b35a: Image successfully pushed
2a332da70fd1: Image successfully pushed
Pushing tag for rev [2a332da70fd1] on {http: // 192.168.2.75: 5000/v1/repositories/testimage/tags/latest}
Local repository and url viewing status:

[Root @ docker5 registry] # ll
Total 4
Drwxr-xr-x. 6 root 4096 Jun 22 14: 27 images
Drwxr-xr-x. 3 root 20 Jun 22 14: 27 repositories
[Root @ docker5 registry] # du-sh ./*
68 M./images
16 K./repositories
[Root @ docker5 registry] # curl http: // 192.168.2.75: 5000/v1/search
{"Num_results": 1, "query": "", "results": [{"description": "", "name ": "library/testimage"}]} [root @ docker5 registry] #
Local repository image download test:
Go to another intranet machine to download the image, for example, my other testing machine 192.168.2.76. The operation is as follows:
First, go to modify the docker configuration file and restart

OPTIONS = '-- selinux-enabled -- insecure-registry 192.168.2.75: 100', where -- insecure-registry 192.168.2.75: 5000 is the address of the local repository you have added.
The pull process is as follows:

[Root @ docker6 ~] # Systemctl restart docker
[Root @ docker6 ~] # Docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
[Root @ docker6 ~] # Docker pull 192.168.2.75: 5000/testimage
Using default tag: latest
2a332da70fd1: Download complete
Listen 474eb5b4: Download complete
B48a20c39b28: Download complete
C79ebe41b35a: Download complete
Status: Downloaded newer image for 192.168.2.75: 5000/testimage: latest
192.168.2.75: 5000/testimage: this image was pulled from a legacy registry. Important: This registry version will not be supported in future versions of docker.
 
[Root @ docker6 ~] # Docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
192.168.2.75: 5000/testimage latest 2a332da70fd1 2 weeks ago 196.7 MB
No problem. The local repository is successfully built.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.