A:node
openssl req \ -newkey rsa:4096 -nodes -sha256 -keyout ./domain.key \ -x509 -days 365 -out ./domain.crt Country Name (2 letter code) [AU]:CN State or Province Name (full name) [Some-State]:GD Locality Name (eg, city) []:SZ Organization Name (eg, company) [Internet Widgits Pty Ltd]:COMPANY Organizational Unit Name (eg, section) []:IT_SECTION Common Name (e.g. server FQDN or YOUR name) []:your.domain.com Email Address []:
注意:Common Name (e.g. server FQDN or YOUR name) []:your.domain.com 這一步填入域名git
啓動(證書位置替換爲本身的):docker
docker run -d \ --restart=always \ --name registry \ -v /root/certs:/certs \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ -p 5000:5000 \ registry:2
B:服務器
vi /etc/hosts 加入 192.168.1.3 your.domain.com 注意:A服務器上填寫的域名dom
複製第一步中生成的 domain.crt 到 /etc/docker/certs.d/myregistrydomain.com:5000/ca.crt,路徑中的域名注意替換成實際第一步中填寫的rest
重啓dockercode
sudo systemctl daemon-reload sudo systemctl restart docker