Docker private warehouse construction

Private repository (environment: centos 7)

(1) Open the private warehouse container, and map the local physical directory /myregistry to the directory where the mirror is stored in the private warehouse, in order to backup and facilitate expansion.

docker run -d -p 5000:5000 -v /myregistry:/var/lib/registry registry:2

(2) Modify the docker.service file and add the IP address and port number of the server of the private warehouse

vim /usr/lib/systemd/system/docker.service

Add to;

ExesStart=/usr/lib/dockerd --insecure-registry 172.16.221.185:5000

Note: The IP address here can be modified according to the actual situation.

(3) Reload the daemon and restart the service

systemctl daemon-reload

systemctl restart docker.servcer

(4) Do not close the docker container due to restarting the service, so start the warehouse container and check whether port 5000 is open.

docker start repository container id

netstat -anpt | grep 5000

(5) Newly pull a mirror, and then change the name (used to recognize and distinguish public mirrors for yourself) to generate a new mirror.

docker pull centos

docker tag id 172.16.221.185:5000/centosnew

(6) Upload the renamed image to the private repository

docker push 172.16.221.185:5000/centosnew

 

(7) Verify that the private library directory in the container exists

curl 172.16.221.185:5000/v2/_catalog

(8) Check whether the mapped local directory has a mirror

cd /myregistry/docker/registry/v2/repositories

(9) Delete the local container, keep the warehouse image and warehouse container, and then pull the verification

docker pull  172.16.221.185:5000/centosnew

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324930647&siteId=291194637