Docker's registry private warehouse building
Private warehouse to official docker registry usage
https://yeasy.gitbooks.io/docker_practice/repository/registry.html
1. Download the registry mirror and start a private warehouse container
(1) Download
docker pull registry
Private repository will be created in the container at / var / lib / registry, so -v parameters are stored by the image file to the local / opt / data / registry port mapping vessel port 5000 to port 5000 of the host
(2) Start
docker run -d -p server port: container port -v server directory: private warehouse container directory
docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registry registry
(3) Test Run
Start checking the registry container
docker ps
Test Connection container
# Telnet server IP port (according to the port running)
telnet 10.0.0.209 5000
Direct access to the browser
http: // ip + port ( 5000 ) to test / v2 / _catalog
Page there is shown below
2. Modify image tag
At the beginning of the address of the port docker registry
# Syntax: docker tag original image name server IP: 5000 / mirror name
Such as:
# docker tag centos 10.0.0.209:5000/mycentos
This time we encounter a https Restrict push mirror problem
3. solve non- HTTPS way to push the mirror problem
(1) Modify /etc/docker/daemon.json configuration
By cancel this restriction Docker configuration options, where you must write the correct json data
Add a line configuration
The following ip to run a private warehouse ip, port 5000
[root@node209 ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://t7h7r7wr.mirror.aliyuncs.com"],
"insecure-registries":["10.0.0.209:5000"]
}
(2) adding /lib/systemd/system/docker.service configuration
Written to [-Service] configuration block, this configuration file is loaded
vim /lib/systemd/system/docker.service
Add a line configuration
EnvironmentFile=-/etc/docker/daemon.json
Screenshot results are as follows:
(3) reload docker and reboot and restart the warehouse container
Reload docker
systemctl daemon-reload
Restart docker
systemctl restart docker
Restart container warehouse
# Docker ps -a # find registry vessel image corresponding to the ID
# Dokcer start container ID
(4) push local mirroring
# docker push 10.0.0.209:5000/mycentos
5. Check the push case
Since docker registry no web interface, but it provides API data
To see the image has been uploaded, you can see at the following link :
Official website tutorial: https://docs.docker.com/registry/spec/api/#listing-repositories
Note : 10.0.0.209 for the deployment of the warehouse server IP
Act One:
curl http://10.0.0.209:5000/v2/_catalog
Act II:
Browser to access http: //10.0.0.209.10: 5000 / v2 / _catalog
Act One: Screenshot
Act II: Screenshot
Mirroring can be uploaded to a private warehouse was successful
6. Delete local mirror, download from private warehouse
#docker rmi 10.0.0.209:5000/mycentos # delete just upload a local mirror
#docker pull 10.0.0.209:5000/mycentos # from a private warehouse pull downloaded image
#docker images # View Mirror