1. Pull the warehouse image registry on the server m01.
[root@m01 ~]#docker pull registry
2. Run the docker private warehouse image on the server m01 to create the container my registry.
[root@m01 ~]#docker run -d -p 5000:5000 --restart=always --name my-registry \ -v /registry:/registry \ -e REGISTRY_STORAGE_DELETE_ENABLED=true \ -e REGISTRY_HTTP_ADDR=0.0.0.0:5000 \ registry:latest 05d5fb3d5e90446703022e86ea80aca762693b730764a3e755af4e210473d405 [root@m01 ~]#
Description -d, run container-p 5000:5000 in the background, and map the container 5000 port to the host 5000 port.
restart always, set the restart policy, and automatically restart the container my registry when docker is restarted.
-Name my registry, name the container- v /registry:/registry. Load the data of the / registry directory in the docker container into the / registry directory of the host. If the / registry directory of the host does not exist, it will be created automatically. The purpose is to prevent the image in the docker private warehouse from being deleted when the container is deleted. The private warehouse image viewed by the host is in this directory- e REGISTRY_STORAGE_DELETE_ENABLED to set whether to delete the image stored in the warehouse- e REGISTRY_HTTP_ADDR=0.0.0.0:5000, set the address of the image warehouse.
3. View the private warehouse image. There is no image for the time being.
[root@m01 ~]#yum install -y tree [root@m01 ~]#tree /registry/ /registry/ 0 directories, 0 files [root@m01 ~]# [root@m01 ~]#curl http://10.0.0.61:5000/v2/_catalog {"repositories":[]}
3, docker client m01 test upload and download private warehouse image
#The following image uses Dockerfile to package Nginx+php image [root@web01 ~]#docker images REPOSITORY TAG IMAGE ID CREATED SIZE mycentos8 nginx c757fb615c03 11 hours ago 383MB #Put a new label on the image (when the first part of the label is the host name and port, docker will interpret it as the location of the image warehouse when uploading the image) [root@web01 ~]#docker tag mycentos8:nginx 10.0.0.61:5000/client-nginx-php [root@web01 ~]#docker images REPOSITORY TAG IMAGE ID CREATED SIZE 10.0.0.61:5000/client-nginx-php latest c757fb615c03 11 hours ago 383MB mycentos8 nginx c757fb615c03 11 hours ago 383MB #Push the tagged image to the private warehouse
3docker client wb01 uploads and creates the image of the new tag to private warehouse server m01.
[root@web01 ~]#docker push 10.0.0.61:5000/client-nginx-php Using default tag: latest The push refers to repository [10.0.0.61:5000/client-nginx-php] Get "https://10.0.0.61:5000/v2/": http: server gave HTTP response to HTTPS client [root@web01 ~]# Use default tag: latest Push refers to the repository[10.0.0.61:5000/client nginx-php] Get“ https://10.0.0.61:5000/v2/": http:server towards HTTPS The client provides http response
4. Solve error reporting
Configure the private warehouse ip and port on the client and restart docker
[root@web01 ~]#cat /etc/docker/daemon.json { "insecure-registries": ["10.0.0.61:5000"] } [root@web01 ~]#systemctl restart docker
5. Upload again (successful):
[root@web01 ~]#docker push 10.0.0.61:5000/client-nginx-php Using default tag: latest The push refers to repository [10.0.0.61:5000/client-nginx-php] 3ccd68eee53e: Pushed 0b386fa14218: Pushed 59674775b440: Pushed b6f8cb70f36a: Pushed 74ddd0ec08fa: Pushed latest: digest: sha256:3778f9d89b90871eecf64cbf82e74ec639e235f6a0709eee6e6682465bb36acd size: 1371 [root@web01 ~]#
6 view the image warehouse:
[root@web01 ~]#curl http://10.0.0.61:5000/v2/_catalog {"repositories":["client-nginx-php"]} [root@web01 ~]#
7 open the web02 machine and configure the ip and port of the image warehouse
[root@web02 ~]#docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos latest 5d0da3dc9764 3 months ago 231MB [root@web02 ~]#vim /etc/docker/daemon.json [root@web02 ~]# [root@web02 ~]#cat /etc/docker/daemon.json { "insecure-registries": ["10.0.0.61:5000"] } [root@web02 ~]#systemctl restart docker [root@web02 ~]#
8. Download the images in the m01 image warehouse in web02:
[root@web02 ~]#docker pull 10.0.0.61:5000/client-nginx-php Using default tag: latest latest: Pulling from client-nginx-php a1d0c7532777: Pull complete 905284dea9d2: Pull complete ac5b4cb41214: Pull complete bdcee17e4cff: Pull complete 067c9ab657be: Pull complete Digest: sha256:3778f9d89b90871eecf64cbf82e74ec639e235f6a0709eee6e6682465bb36acd Status: Downloaded newer image for 10.0.0.61:5000/client-nginx-php:latest 10.0.0.61:5000/client-nginx-php:latest [root@web02 ~]#docker images REPOSITORY TAG IMAGE ID CREATED SIZE 10.0.0.61:5000/client-nginx-php latest c757fb615c03 4 hours ago 383MB centos latest 5d0da3dc9764 3 months ago 231MB [root@web02 ~]#
4, Browse and delete the docker private warehouse image using the web interface
1. The private warehouse server m01 downloads the docker registry web image of the web interface management tool.
[root@m01 ~]#docker pull hyper/docker-registry-web
2. Set the private warehouse read-only parameter to false and create the startup container registry web.
docker run -itd -p 8080:8080 --restart=always --name registry_web --link my-registry \ -e REGISTRY_URL=http://10.0.0.61:5000/v2 \ -e REGISTRY_NAME=10.0.0.61:5000 \ -e REGISTRY_READONLY=false \ hyper/docker-registry-web:latest
3. If there is a firewall, please open port 8080:
firewall-cmd --zone=public --add-port=8080/tcp --permanent firewall-cmd --reload firewall-cmd --zone=public --query-port=8080/tcp
4. Docker private warehouse server 200, edit the configuration file / etc / docker / daemon JSON, add the content "private warehouse IP: port number", save the configuration file and restart the docker service.
[root@m01 ~]#vi /etc/docker/daemon.json [root@m01 ~]#cat /etc/docker/daemon.json { "registry-mirrors": [ "http://hub-mirror.c.163.com" ], "insecure-registries": ["10.0.0.61:5000"] } [root@m01 ~]#systemctl restart docker [root@m01 ~]#
5 LAN browser access http://10.0.0.61:8080/ You can view and delete mirrors