: This article mainly introduces Docker: building a private repository. if you are interested in the PHP Tutorial, refer to it. Continue. This document describes the simplest steps for building a private repository.
In summary:
- Install the registry image and start the container.
- CA certificate (another way is to use HTTP directly, you can skip this step)
- Create and release an image.
The simplest way to install Registry is to directly Pull a ready-made Registry image.
docker pull registry
Then start it.
docker run -p5000:5000-v /home/registry:/tmp/registry registry
Expose port 5000 to external services, and load the/home/registry Directory of the host as the repository directory.
Now you can push your image to this warehouse. you need to tag an image and then PUSH it. the command is as follows:
docker tag java:7-jre hub.wo.cn/yancheng/javadocker push hub.wo.cn/yancheng/java
At this time, a security error is inevitable:
From the error description, there are two solutions: HTTP and CA certificate installation.
Method 1: configure HTTP to be faster and simpler. You only need to modify the/etc/default/docker file and add the following sentence:
DOCKER_OPTS="$DOCKER_OPTS --insecure-registry=hub.open.wo.cn"
Then restart Docker,sudo service docker restart
.
Method 2: Configuring the security certificate is a little troublesome, especially when our docker registry is behind nginx.
First, you need to generate your own certificate (to operate on the server). The command is as follows:
openssl genrsa -des3 -out hub.key2048openssl rsa -in hub.key -out hub_nopwd.keyopenssl req -new -key hub_nopwd.key -out hub.csropenssl x509 -req -days 3650 -in hub.csr -signkey hub_nopwd.key -out hub.crt
Then, Configure Nginx to support HTTPS.
server { listen 443; server_name hub.wo.cn; ssl on; ssl_certificate /usr/local/nginx/conf/hub.crt; ssl_certificate_key /usr/local/nginx/conf/hub_nopwd.key; location / { proxy_pass http://10.250.251.20:5000; proxy_redirect off; proxy_set_header Host $host; proxy_set_header x-forwarded-for$remote_addr; }}
Note the location of hub. crt and hub_nopwd.key. Restart nginx.
Now, you need to get the hub. crt locally and put it in the corresponding directory as prompted. That is:/etc/docker/certs.d/hub.open.wo.cn
.
Restart docker again and push again.
'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
'). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script
The above introduces Docker: the establishment of a private warehouse, including some content. I hope my friends who are interested in the PHP Tutorial will help me.