The method of setting up docker local mirror warehouse under centos7 system

  • 2020-05-24 06:39:49
  • OfStack

System environment: CentOS 7.2

192.168.0.179: Docker warehouse

192.168.0.60: client

Install and start docker


yum -y install docker
systemctl start docker
systemctl enable docker

Build a private warehouse

Download the registry image from 179


docker pull registry

Firewall added run 5000 port


iptables -I INPUT 1 -p tcp --dport 5000 -j ACCEPT

After downloading, we start a container with the image


docker run -d -p 5000:5000 --privileged=true -v /opt/registry:/tmp/registry registry

Parameter description:

- v/opt/registry: / tmp/registry: by default, the warehouse will be stored within the container/tmp registry directory, specify the local directory mounted to the container Security module in the � privileged = true: CentOS7 selinux banned from the permissions, parameter add privileges to the container, don't add the mirror will be submitted to the authority error (OSError: [13] Errno Permission denied: '/ tmp/registry/repositories/liibrary') or (Received unexpected HTTP status: 500 Internal Server Error) error

The client uploads the image

Modify/etc sysconfig/docker (Ubuntu configuration file under the address is: / etc init/docker conf), increase the boot option (parameters have been established in attach), after the restart docker, don't add an error, https certificate issue.


OPTIONS='--insecure-registry 192.168.0.179:5000' #CentOS 7 system 
other_args='--insecure-registry 192.168.0.179:5000' #CentOS 6 system 

Since Docker interacts with docker registry from 1.3.X, https is used by default, and the private warehouse set up here only provides http service to download one image from docker public warehouse


docker pull docker.io/centos

Modify the tag of the image by 1


docker tag centos 192.168.0.179:5000/centos

Upload the tag image to the private repository


docker push 192.168.0.179:5000/centos

The client adds the private warehouse address


#  Add this 1 line 
ADD_REGISTRY='--add-registry 192.168.0.179:5000'

When added, search mirror, private warehouse and docker hub will be displayed.

Without searching for a private repository, specify the private repository ip in the command

Use the mirror in the repository

To query all images in the private warehouse, use the docker search command:


curl -u myuser https://registry_ip:5000/v1/search
curl registry_ip:5000/v1/search

docker search registry_ip:5000/  #centos 7
docker search registry_ip:5000/library #centos 6

To query the image under the specified account in the warehouse, use the following command:


docker pull registry
0

Related articles: