Centos7 docker build private repository registry

Source: Internet
Author: User
Tags docker hub

Centos7 docker build private repository registry

Environment Planning:

Docker private repository address: 192.168.0.167

Docker client address: 192.168.0.167

· Disable firewall and selinux

systemctlstopfirewalld.service systemctldisablefirewalld.service #vi/etc/sysconfig/selinux SELINUX=disabled #setenforce0

Server

1. Install and start docker

yum-yinstalldocker servicedockerstart chkconfigdockeron

2. Pull the local private repository registry

[root@localhost~]#dockerpullregistry Tryingtopullrepositorydocker.io/registry... 24dd746e9b9f:Downloadcomplete 706766fe1019:Downloadcomplete a62a42e77c9c:Downloadcomplete 2c014f14d3d9:Downloadcomplete b7cf8f0d9e82:Downloadcomplete d0b170ebeeab:Downloadcomplete 171efc310edf:Downloadcomplete 522ed614b07a:Downloadcomplete 605ed9113b86:Downloadcomplete 22b93b23ebb9:Downloadcomplete 2ac557a88fda:Downloadcomplete 1f3b4c532640:Downloadcomplete 27ebaac643a7:Downloadcomplete ce630195cb45:Downloadcomplete Status:Downloadednewerimage for docker.io/registry:latest

3. view the registry Image

[root@localhost~]#dockerimages docker.io/busyboxlatest0064fda8c45d5daysago1.113MB docker.io/registrylatest105c6c9299d95daysago423.3MB docker.io/centoslatestce20c473cd8a6daysago172.3MB

4. Run containers based on private repository Images

By default, the repository is stored in the/tmp/registry directory of the container. If the container is deleted, the image stored in the container will also be lost, therefore, we usually specify a local directory to be mounted to the/tmp/registry directory of the container!

· The default storage path of registry is/tmp/registry, which is only a temporary directory and will disappear after a period of time

· Use the-v parameter to specify a local persistent path,

[root@localhost~]#dockerrun-d-p5000:5000-v/opt/data/registry:/tmp/registrydocker.io/registry bb2c0d442df94e281479332c2608ef144f378e71743c5410e36b80c465771a95 root@localhost~]#dockerps-a CONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMES bb2c0d442df9docker.io/registry:latest "docker-registry" 10secondsagoUp7seconds

5. Access a private Repository

[root@localhost~]#curl127.0.0.1:5000/v1/search { "num_results" :0, "query" : "" , "results" : []} # The Private repository is empty. No new image is submitted to the repository.

6. Pull an image from Docker HUB to test

[root@localhost~]#dockerpullbusybox [root@localhost~]#dockerimages REPOSITORYTAGIMAGEIDCREATEDVIRTUALSIZE docker.io/busyboxlatest0064fda8c45d5daysago1.113MB docker.io/registrylatest105c6c9299d95daysago423.3MB docker.io/centoslatestce20c473cd8a6daysago172.3MB

7. Create an image link to tag the basic image

[root@localhost~]#dockertagdocker.io/busybox192.168.0.167:5000/busybox [root@localhost~]#dockerimages REPOSITORYTAGIMAGEIDCREATEDVIRTUALSIZE 192.168.0.167:5000/busyboxlatest0064fda8c45d5daysago1.113MB docker.io/busyboxlatest0064fda8c45d5daysago1.113MB docker.io/registrylatest105c6c9299d95daysago423.3MB docker.io/centoslatestce20c473cd8a6daysago172.3MB

8. Modify the docker configuration file and specify the private repository url

[root@localhost~]#vim/etc/sysconfig/docker Modify this line OPTIONS= '--insecure-registry192.168.0.167:5000' [root@localhost~]#servicedockerrestart

9. Upload the image to a local private Repository

dockerpush192.168.0.167:5000/busybox

10. Check whether the private repository has the corresponding image

[root@localhost~]#curl192.168.0.167:5000/v1/search { "num_results" :1, "query" : "" , "results" :[{ "description" : "" , "name" : "library/busybox" }]}

11. view the storage directories and files of images

[root@localhost~]#tree/opt/data/registry/repositories/ /opt/data/registry/repositories/ └──library └──ssh ├──_index_images ├──json ├──tag_latest └──taglatest_json 2directories,4files

Client

1. Install and start docker

yum-yinstalldocker servicedockerstart chkconfigdockeron

2. Modify the docker configuration file and specify the private repository url

[root@localhost~]#vim/etc/sysconfig/docker Modify this line OPTIONS= '--insecure-registry192.168.0.167:5000' [root@localhost~]#servicedockerrestart

3. Test and download the uploaded image.

[root@localhost~]#dockerpull192.168.0.167:5000/busybox [root@localhost~]#dockerimages REPOSITORYTAGIMAGEIDCREATEDVIRTUALSIZE 192.168.0.167:5000/busyboxlatest0064fda8c45d5daysago1.113MB docker.io/registrylatest105c6c9299d95daysago423.3MB docker.io/centoslatestce20c473cd8a6daysago172.3MB docker.io/atcol/docker-registry-uilatestd838355ad9036monthsago890.5MB

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.