Due to network restrictions on domestic effort network, directly pulled from the docker native warehouse mirror, takes a very long time, or even timeout timeout.
Therefore, often mirroring group docker of time, needs to be changed to accelerate domestic sources (such as Ali cloud sources), but this mode of operation, you need to configure each server individually docker, management is very inconvenient and very time-consuming.
And intranet environment, for security reasons, not all servers are put through to access the Internet / extranet access to it, and therefore can not access the Internet mirrored warehouse.
Thus, to find a machine commonly used to build a private repository, to accelerate the machine from a source outside the network pulling docker mirror and then directed to the source server configuration docker private repository server, so that the network can be pulled directly from the private warehouse take the mirror.
This introduction how to build a private warehouse, the docker how to modify the server configuration to a local warehouse.
lab environment:
Operating System: CentOS7
Machine IP: choose kubernetes the Master Host (10.1.30.24)
1, first configure mirroring accelerate the host warehouse
Ali cloud access the link, you can create a free docker mirror accelerator. (Need to register on their own account, then enable, there will be a string of token code)
we /etc/docker/daemon.json
{ "registry-mirrors": ["https://XXXXXXXX.mirror.aliyuncs.com"] }
XXXXXXXX fill in their actual token, then you need to run the following command to reload take effect.
systemctl daemon-reload systemctl restart docker
Pulling back and found a lot of speed has improved significantly.
2, modifying the host table
Master and Node needs to modify (or directly increase the resolution records in the DNS server)
vi /etc/hosts
10.1.30.34 registry
(Hereinafter Master operation only)
3, warehouse host registration
docker pull registry
# Warehouse host registration
docker run -d -v /registry:/var/lib/registry -p 5000:5000 --restart=always --privileged=true --name registry registry:latest
docker pull hello-world
# Download a lightweight mirror test
4, tagging and uploading image
Mirror warehouse works as follows:
Docker official source from warehouse server / source to accelerate pull mirror ( pull ), then there is a local warehouse server after pulling the mirror again playing tag ( Tag ), and then hit the local mirror after the label re-upload to the warehouse ( the Push )
docker tag hello-world registry:5000/hello-world:latest
docker push registry:5000/hello-world:latest
It is expected to be given as follows
Get https:// 10.1.30.34:5000:5000/v1/_ping: http: server gave HTTP response to HTTPS client
Because the current configuration only supports http, does not support https, you need to modify the configuration.
we /etc/docker/daemon.json
{ "registry-mirrors": ["https://njrds9qc.mirror.aliyuncs.com"], "insecure-registries":["registry:5000"] }
5, image tagging and uploading
systemctl daemon-reload systemctl restart docker
docker push registry:5000/hello-world:latest
Enter the following command to view mirror has been uploaded
docker images
or
curl http://registry:5000/v2/_catalog
(Hereinafter Node operations only)
6, modify Node node configuration repository
we /etc/docker/daemon.json
{ "registry-mirrors": ["https://XXXXXXXX.mirror.aliyuncs.com"], "insecure-registries":["registry:5000"] }
# Append a row to perform registry, pay attention to the top line ends with a comma, otherwise it will error.
systemctl daemon-reload systemctl restart docker
# Reload the configuration
7, pulling the test image
Pull tests have already uploaded image
docker push registry:5000/hello-world:latest docker images;
Mirror found success pulls, warehouse build success.