The Docker Hub public repository has the following drawbacks:
1, strong network dependence, link speed limit;
2, privatization of information storage network is not secure
3, the privatization of the warehouse need to charge, there is a security risk
Solution uses local registry
Docker has already said registry open source, and also has an official image on the Docker hub registry
We can use it directly:
(1) Start Registry container
Shell>docker run-d-P 5000:5000-v/myregistry:/var/lib/registry registry:2
Mirroring using the Registry:2
-D Background Run
-P Talk Container 5000 ports mapped to 5000 ports on the host
-V Maps the container/var/lib/registry directory to the/myregistry/docker of the host to hold the mirrored data
Verify: Shell>docker PS to see if the warehouse container is started
(2) Download a test image locally
Shell>docker Pull CentOS
(3) Renaming the local mirror via Docker tag, matching with registry
Shell>docker tag CentOS Warehouse server address: 5000/user name/centos:v1
Shell>docker tag CentOS x.x.x.x:5000/testname/centos:v1
The full format of the repository is:
Docker Hub 上可以省略[registry-host]:[port],默认为docker.io
(4) Docker Pull/push test
Shell>docker Push X.X.X.X:5000/TESTNAME/CENTOS:V1
Shell>docker Pull X.x.x.x:5000/testname/centos:v1
(5) The uploaded image is in this directory
/myregistry/docker/registry/v2/repositories/docker39/cetnos_httpd/
Tips:
Shell>docker Pull X.x.x.x:5000/testname/cetnos
Using default Tag:latest
Error response from Daemon:get https://x.x.x.x:5000/v2/: Http:server gave HTTP response to HTTPS client
This is Docker does not support HTTPS
CentOS System through: Modify or add Daemon.json file, restart Docker service can
Shell>vim/etc/sysconfig/daemon.json
{"Insecure-registries": ["x.x.x.x:5000"]}
Shell>systemctl Restart Docker//Restart service, remember to start the Registry warehouse container
Docker Build Local warehouse