Docker: Building a private warehouse

Source: Internet
Author: User
Tags openssl rsa docker registry
Continue, this article describes the simplest steps of building a private warehouse.

For the summary:

    1. Install the registry image and start the container.
    2. CA certificate (There is also a way to directly use HTTP also line, you can omit this step)
    3. Make the image, publish it.

The simplest way to install registry is to pull a ready-made registry image directly.

docker pull registry

Then start it.

-p5000:5000-v /home/registry:/tmp/registry registry

Exposes 5000 ports for external service, while loading the host's/home/registry directory as a warehouse directory.

Now you can push your own image to this warehouse, you need to first give a mirror tag, and then push it, the command is as follows:

docker tag java:7-jre hub.wo.cnpush hub.wo.cn/yancheng/java

At this point, a security error must be reported:

From the error description, there are two solutions, one is to use HTTP, and the other is to install the CA certificate.

Method one, configured as HTTP, the speed will be slightly faster, but also simple. Just modify the/etc/default/docker file, plus one sentence:

DOCKER_OPTS="$DOCKER_OPTS --insecure-registry=hub.open.wo.cn"

Then restart Docker, sudo service docker restart and the normal push will be done.

Method Two, configure the security certificate, slightly cumbersome, especially our Docker registry behind Nginx.

First, you need to generate your own certificate (to operate on the server) with the following command:

openssl genrsa -des3 -out hub.key2048openssl rsa -in hub.key -out hub_nopwd.keyopenssl req -new -key hub_nopwd.key -out hub.csr3650 -in hub.csr -signkey hub_nopwd.key -out hub.crt

Then, we configure the Nginx to increase the support for 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;   / {        proxy_pass http://10.250.251.20:5000;        proxy_redirect off;        $host;        proxy_set_header x-forwarded-for$remote_addr;   }}

Note the location of the HUB.CRT and Hub_nopwd.key. Restart Nginx.

Now, you need to get this hub.crt locally, and follow the previous prompts in the appropriate directory. That is: /etc/docker/certs.d/hub.open.wo.cn .

Restart Docker again, and push is normal.

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the Docker: private warehouse building, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.