CentOS 7 builds Docker private warehouse

Source: Internet
Author: User
Tags docker hub

Docker's private warehouse was unsuccessful during the learning of Docker, because the CentOS 6.x and CentOS 7 default introduced support for HTTPS authentication, and each time the push and pull errors were made, today is the weekend, The use of a day of repeated testing and online case integration, is finally successful, but also to take this opportunity to learn Docker friends help.

Personal humble Opinion: Bo friends in the practice of the proposed CentOS 7.x system, do not recommend the CentOS 6.x system


First, prepare

Address planning:

Docker Private Warehouse Address: 192.168.0.109Docker Client Address: 192.168.0.110

1. Activating the network card

# vim/etc/sysconfig/network-scripts/ifcfg-eno16777728 Modify this line onboot=yes#/etc/init.d/network restart

2. Turn off the local firewall and set the boot not self-booting

# systemctl Stop firewalld.service# systemctl disable Firewalld.service

3. Close the local SELinux firewall

# Vi/etc/sysconfig/selinux selinux=disabled# Setenforce 0

4. Installing Ifconfig Tools

# yum Install Net-tools

Second, installation

1. Installing Docker

# yum install docker# Yum Upgrade device-mapper-libs# service Docker start# Chkconfig Docker on

2. Local private Warehouse Registry

[[Email protected] ~]# docker pull registrytrying to pull repository  DOCKER.IO/REGISTRY&NBSP, ..... 24DD746E9B9F: DOWNLOAD COMPLETE 706766FE1019: DOWNLOAD COMPLETE A62A42E77C9C:  download complete 2c014f14d3d9: download complete b7cf8f0d9e82: download  complete d0b170ebeeab: download complete 171efc310edf: download complete  522ed614b07a: Download complete 605ed9113b86: Download complete  22b93b23ebb9: download complete 2ac557a88fda: download complete 1f3b4c532640:  download complete 27ebaac643a7: download complete ce630195cb45: download  complete status: downloaded newer image for docker.io/registry:latest[[ email protected] ~]# docker imagesrepository            tag                  IMAGE ID            CREATED              virtual sizedocker.io/registry    latest               24dd746e9b9f        3 days ago           413.8 mb

3. Run a container based on a private warehouse image

[[email protected] ~]# docker run -d -p 5000:5000 -v /opt/data/ Registry:/tmp/registry docker.io/registrybb2c0d442df94e281479332c2608ef144f378e71743c5410e36b80c465771a95 [[email protected] ~]# docker ps -acontainer id         IMAGE                        COMMAND              CREATED              STATUS              PORTS                      NAMESbb2c0d442df9        docker.io/registry:latest     "Docker-registry"    10 seconds ago      up 7 seconds         0.0.0.0:5000->5000/tcp   serene_hopper

4. Access to private warehouses

[[email protected] ~]# Curl 127.0.0.1:5000/v1/search{"Num_results": 0, "Query": "", "Results": []}//Private Warehouse is empty, no new image is submitted to the warehouse

5. Download an SSH image from the Docker hub

[[email protected] ~]# docker search -s 10 sshname                                DESCRIPTION   STARS      OFFICIAL   AUTOMATEDdocker.io: docker.io/fedora/ssh                  18                    [ok][[email protected]  ~]# docker pull fedora/sshtrying to pull repository docker.io/fedora/ SSH&NBSP, ..... 2AEB2B6D9705: DOWNLOAD COMPLETE 511136EA3C5A: DOWNLOAD COMPLETE 00A0C78EEB6D:  download complete 834629358fe2: download complete 571e8a51403c: download  complete&nbsP;87D5D42E693C: DOWNLOAD COMPLETE 92B5EF05FE68: DOWNLOAD COMPLETE 92D3910DC33C:  Download complete cf2e9fa11368: Download complete Status: Downloaded  newer image for docker.io/fedora/ssh:latest[[email protected] ~]# docker  imagesrepository             tag                  IMAGE ID             CREATED              VIRTUAL SIZEdocker.io/registry      latest              24dd746e9b9f         3 days ago           413.8&nbsP mbdocker.io/fedora/ssh   latest               2aeb2b6d9705        9 days ago           254.4 mb

6. Create a mirrored link or label the underlying image

[[Email protected] ~]# docker tag docker.io/fedora/ssh 127.0.0.1:5000/ssh[[email  protected] ~]# docker imagesREPOSITORY              TAG                  IMAGE ID             CREATED             VIRTUAL  sizedocker.io/registry     latest               24dd746e9b9f        3 days  ago          413.8 MBdocker.io/fedora/ssh    latest               2aeb2b6d9705        9 days ago          254.4  mb127.0.0.1:5000/ssh     latest               2aeb2b6d9705        9 days ago           254.4 mb

7. Modify the Docker configuration file to make a private warehouse URL

[[email protected] ~]# Vim/etc/sysconfig/docker Modify this line options= '--selinux-enabled--insecure-registry 192.168.0.109:5000 ' [[email protected] ~]# service Docker restartredirecting to/bin/systemctl restart Docker.service

8. Submit the image to the local private warehouse

[[email protected] ~]# docker push  127.0.0.1:5000/sshthe push refers to a repository [127.0.0.1:5000/ssh]  (len :  1) sending image listpushing repository 127.0.0.1:5000/ssh  (1 tags) 511136ea3c5a: image successfully pushed 00a0c78eeb6d: image successfully  pushed 834629358fe2: image successfully pushed 571e8a51403c: image  successfully pushed 87d5d42e693c: image successfully pushed 92b5ef05fe68:  image successfully pushed 92d3910dc33c: image successfully pushed  cf2e9fa11368: image successfully pushed 2aeb2b6d9705: image successfully  pushed pushing tag for rev [2aeb2b6d9705] on {http://127.0.0.1:5000/v1/ Repositories/ssh/tags/latest} 

9. See if there is a corresponding mirror in the private warehouse

[[email protected] ~]# Curl 127.0.0.1:5000/v1/search{"Num_results": 1, "Query": "", "results": [{"description": "", "name ":" Library/ssh "}]}

10. View the mirrored storage directory and files

[Email protected] ~]# TREE/OPT/DATA/REGISTRY/REPOSITORIES//OPT/DATA/REGISTRY/REPOSITORIES/└──LIBRARY└──SSH ├──_index_images├──json├──tag_latest└──taglatest_json2 directories, 4 files

Third, download the existing image from the private warehouse

1. Log in to another Docker client

[[email protected] ~]# ssh [email protected]the authenticity of host ' 192.168.0.110 (192.168.0.110) ' can ' t be established. ECDSA Key fingerprint is 5b:81:4b:66:d6:dd:48:16:9f:85:58:72:21:bd:ba:39.are you sure you want to continue connecting (yes /no)? yeswarning:permanently added ' 192.168.0.110 ' (ECDSA) to the list of known hosts. [email protected] ' s password:last login:sun Apr 14:39:51 from 192.168.0.103

2. Modify the Docker configuration file

[[email protected] ~]# Vim/etc/sysconfig/docker Modify this line options= '--selinux-enabled--insecure-registry  192.168.0.109:5000 '//Add private warehouse address [[email protected] ~]# service Docker restartredirecting to/bin/systemctl restart Docker.service

3. Download the existing image from the private warehouse

[[Email protected] ~]# docker pull 192.168.0.109:5000/sshtrying to pull  REPOSITORY 192.168.0.109:5000/SSH&NBSP, ..... 2AEB2B6D9705: DOWNLOAD COMPLETE 511136EA3C5A: DOWNLOAD COMPLETE 00A0C78EEB6D:  download complete 834629358fe2: download complete 571e8a51403c: download  complete 87d5d42e693c: download complete 92b5ef05fe68: download complete  92d3910dc33c: download complete cf2e9fa11368: download complete status:  downloaded newer image for 192.168.0.109:5000/ssh:latest[[email protected]  ~]# docker imagesREPOSITORY                TAG                  image id         &Nbsp;  created             virtual  SIZE192.168.0.109:5000/ssh   latest               2aeb2b6d9705        9 days ago           254.4 mb

Iv. browser access to the warehouse

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/FB/wKioL1U8yD2CICJXAACRXA3Ij1w707.jpg "title=" 1.png " alt= "Wkiol1u8yd2cicjxaacrxa3ij1w707.jpg"/>

This article is from the "Zheng" blog, make sure to keep this source http://467754239.blog.51cto.com/4878013/1638770

CentOS 7 builds Docker private warehouse

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.