How to create docker registry mirror on CentOS

2019-01-15 22:41发布

问题:

I try and try to create mirror in docker-registry. I have read the tutorial in this. And use the way in this. I'm sure I have add variable to docker daemon. And I succeed on mac OS X. But it didn't work at all on my centOS.

I run my docker daemon using this command:

docker -g /opt/apps/docker/lib --insecure-registry http://10.11.150.76:5555 --registry-mirror=http://10.11.150.76:5555 -d

and I use this command to check docker daemon:

ps -ef | grep "docker"

It really has added to docker:

root      1232 30203  0 20:47 ?        00:00:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 10022 -container-ip 172.17.0.22 -container-port 22
root      1322   735  0 20:57 pts/7    00:00:00 grep --color=auto docker
root     30202     1  0 20:15 ?        00:00:00 sudo http_proxy=http://10.16.10.129:9526/ docker -g /opt/apps/docker/lib --insecure-registry http://10.11.150.76:5555 --registry-mirror=http://10.11.150.76:5555 -d

Then, I use this command to create mirror:

docker run -d -p 5555:5000 -e STORAGE_PATH=/mirror -e STANDALONE=false -e MIRROR_SOURCE=https://registry-1.docker.io -e MIRROR_SOURCE_INDEX=https://index.docker.io -v /Users/v11/Documents/docker-mirror:/mirror  --restart=always --name mirror registry

Next,I pull the new image, for example:

docker pull ubuntu

It did't work at all, because I can't find image in my path "/Users/v11/Documents/docker-mirror". I print the mirror log information and it will show me error information:

ConnectionError: HTTPSConnectionPool(host='index.docker.io', port=443): Max retries exceeded with url: /v1/repositories/library/hello-world/images (Caused by : [Errno 110] Connection timed out)

and docker log :

INFO[0023] POST /v1.19/images/create?fromImage=hello-world%3Alatest ERRO[0027] Unable to create endpoint for http://10.11.150.76:5555/: invalid registry endpoint https://10.11.150.76:5555/v0/: unable to ping registry endpoint https://10.11.150.76:5555/v0/ v2 ping attempt failed with error: Get https://10.11.150.76:5555/v2/: EOF v1 ping attempt failed with error: Get https://10.11.150.76:5555/v1/_ping: EOF. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add --insecure-registry 10.11.150.76:5555 to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/10.11.150.76:5555/ca.crt

I really search many relevant questions to find solving. But I still have no idea about it. How to do it? Thanks.

回答1:

The '--registry-mirror' flag to docker has been designed to only work for mirroring the official docker.io repository. In 2015, they said the registry V2 would be made to work with the '--registry-mirror' flag, but this capability is still unavailable.