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)