Docker: building a private repository

Source: Internet
Author: User
Tags docker run docker registry
: 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:

  1. Install the registry image and start the container.
  2. CA certificate (another way is to use HTTP directly, you can skip this step)
  3. 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.

    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.