CentOS 7: Docker private warehouse setup and use

  • 2020-06-07 05:35:24
  • 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 on 179


docker pull registry

Firewall adds running port 5000


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

After downloading, we start a container with this 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 started from 1.3.X, the default interaction with docker registry is https, while the private warehouse built here only provides http service

Download 1 image from the docker Public repository


docker pull docker.io/centos

To modify tag for 1 of the mirror


docker tag centos 192.168.0.179:5000/centos

Upload the image with tag to the private warehouse


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 images, private warehouses and docker hub are displayed;

Private repository ip is not searched, as specified in the command

Use images in the repository

Query all images in the private repository using 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 mirror under the specified account in the warehouse, use the following command:


docker pull registry
0

Related articles: