七夕小子 2019-06-26
注: 以下内容中的 “192.168.1.130” IP 地址请自行修改为你的 Docker 宿主机的地址。
mkdir -p /data/docker-registry/{auth,certs,lib}
[ v3_ca ] subjectAltName = IP:192.168.1.130 # 增加此行内容
cd /data/docker-registry/certs \ && openssl req -newkey rsa:2048 -nodes -keyout registry_auth.key -x509 -days 365 -out registry_auth.crt update-ca-trust extract
docker run --entrypoint htpasswd registry:2 -Bbn admin r58eYM8wKDvV >> /data/docker-registry/auth/htpasswd
docker run -d -p 5000:5000 --restart=always --name docker-registry \ -v /data/docker-registry/lib:/var/lib/registry \ -v /data/docker-registry/auth:/auth \ -v /data/docker-registry/certs:/certs \ -e "REGISTRY_AUTH=htpasswd" \ -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry_auth.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/registry_auth.key \ registry:2
mkdir -p /etc/docker/certs.d/192.168.1.130\:5000/ \ && cp -f /data/docker-registry/certs/registry_auth.crt /etc/docker/certs.d/192.168.1.130\:5000/ca.crt
docker login -u admin -p r58eYM8wKDvV 192.168.1.130:5000