Build Docker Registry (HTPASSWD certified)

Source: Internet
Author: User
Tags docker run docker registry

1. Pull the Docker registry image

Docker Pull Registry

2. Create a certificate store directory

Mkdir-p/home/registry

3, Generate CA Certificate
Edit your/etc/ssl/openssl.cnf on the logstash host-add subjectaltname = ip:10.1.10.1 inch [V3_ca] section.
In general, the certificate only supports domain name access, to enable it to support IP address access, you need to modify the configuration file OPENSSL.CNF.
In the REDHAT7 system, the Openssl.cnf file is located in/etc/pki/tls/openssl.cnf. In the [V3_ca] section, add the SubjectAltName option:

[V3_ca]subjectaltname = ip:10.1.10.1

Generate certificate

OpenSSL Req-newkey rsa:4096-nodes-sha256-keyout/home/registry/certs/domain.key-x509-days 365-out/home/registry/ce Rts/domain.crt

Note Common name is best written as registry domain name

Modify the permissions and add the authentication file to the (client)/etc/docker/certs.d/10.1.10.1:5000/

Chcon-rt svirt_sandbox_file_t/home/registry/certsmkdir-p/ETC/DOCKER/CERTS.D/10.1.10.1:5000/CP registry/certs/ Domain.crt/etc/docker/certs.d/10.1.10.1:5000/ca.crt

3, generate user name and password file using registry image

Docker run--entrypoint htpasswd registry-bbn Test 1 >/home/registry/auth/htpasswdchcon-rt Svirt_sandbox_file_t/hom e/registry/

4, run registry and specify parameters. Includes the user password file and the CA book location. --restart=always always automatically restarts

Docker run-d-P 5000:5000--restart=always--name registry-v/home/registry/auth:/auth-e "registry_auth=htpasswd"-E "R Egistry_auth_htpasswd_realm=registry REALM "-E registry_auth_htpasswd_path=/auth/htpasswd-v/home/registry/certs:/ Certs-e registry_http_tls_certificate=/certs/domain.crt-e Registry_http_tls_key=/certs/domain.key REGISTRY

5, Landing and logout
# # #vim/etc/hosts

Docker login 10.1.10.1:5000-u uesr-p passworddocker logout 10.1.10.1:5000

6, add user

Docker run--entrypoint htpasswd registry-bbn dapeng 123456 >>/home/registry/auth/htpasswddocker Run--entrypoint htpasswd registry-bbn user123 passwd123 >>/home/registry/auth/htpasswd

No need to perform Docker restart registry

Build Docker Registry (HTPASSWD certified)

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.