Manually build a docker local private image repository

Source: Internet
Author: User
Tags owncloud

Experimental environment: Two centos7 virtual machines, one is server, used as the client, and the other is registry, used as the docker private image repository.

Basic Configuration

Check the IP addresses of the two VMS.
The IP address of the server is192.168.134.151.

The IP address of the Registry is192.168.134.150.

Usesetenforce 0Temporarily disable SELinux.

OpenServerAndRegistryKernel forwarding function
Edit configuration file/etc/sysctl.conf, Add the following content:

net.ipv4.ip_forward = 1 net.ipv4.conf.default.rp_filter = 0 net.ipv4.conf.all.rp_filter = 0 


Usesysctl –pCommand.

Docker Configuration

1. Install the docker Environment
InServerAndRegistryUse on two machinesyum install -y dockerCommand to install the docker environment.

2. Configure the docker configuration file
InServerAndRegistryEdit on/etc/sysconfig/dockerAdd the following two lines to the file:

ADD_REGISTRY='--add-registry 192.168.134.150:5000' INSECURE_REGISTRY='--insecure-registry 192.168.134.150:5000'

Here we willdocker imageTo the local privateRegistry.

Usesystemctl restart dockerCommand to restart docker.

3. Set the docker Service
Set docker to start automatically

systemctl enable docker

4. Configure the image repository
First, put the tar packages of the two images to be used./rootDirectory.

Then manually load the image and LoadregistryAnd then upload the image to the private image repository becauseregistryThe container must be used for registration of other containers.To build a private image repository, you must first start the Registry container.
The command used is as follows:

Docker load <registry_latest.tar // load the image docker images // view the newly loaded image's iddocker run-D-P 5000: 5000 -- restart = always -- Name Registry registry: latest // start the Registry container docker tag image ID Registry: Latest // create a new tag for the Registry image (skip this step) docker push registry: latest // upload the Registry image to the private image repository (skip this step)


Usedocker imagesCheck the local image.

You can see the following is the image I just re-tagged.

Upload an owncloud image.

Here we can see that the uploaded image has no tag, so we can tag it.

Then upload the image to the private image repository.
All commands are as follows:

Docker load <owncloud.tar // load the image docker images // view the newly loaded image's iddocker tag image ID owncloud: Latest // Add tagdocker push owncloud to the owncloud image: latest // upload the owncloud image to the private image repository

The default location of my private image repository is/var/lib/docker/volumes/022dbe58afaec96083a1ceb3fb6672c7a62be38a5a48158322d75d2e6b1150c3/_data/docker/registry/v2/repositories/.
View

Here we can see the image files uploaded to the private image repository.

Verify

Verify that the private image is successfully built.
Pull the owncloud image to the server and try it out.

Here we can see that he is from192.168.134.150 RegistryThe image pulled from the image repository.
This experiment is successful!

Manually build a docker local private image repository

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.