$ mkdir certs
$ openssl genrsa -out ./certs/ca.key 2048
$ openssl req -x509 -new -key ./certs/ca.key -days 10000 -out ./certs/ca.crt
$ openssl genrsa -out ./certs/domain.key 2048
$ openssl req -new -key ./certs/domain.key -subj /CN=${DOCKER_HOST_IP} -out ./certs/domain.csr
$ echo subjectAltName = IP:${DOCKER_HOST_IP} > extfile.cnf
$ openssl x509 -req -in ./certs/domain.csr -CA ./certs/ca.crt -CAkey ./certs/ca.key -CAcreateserial -out ./certs/domain.crt -days 10000 -extfile extfile.cnf
$ htpasswd -c htpasswd alicek106
$ mv htpasswd certs/
$ vi certs/nginx.conf
upstream docker-registry {
server registry:5000;
}
server {
listen 443;
server_name ${DOCKER_HOST_IP};
ssl on;
ssl_certificate /etc/nginx/conf.d/domain.crt; ssl_certificate_key /etc/nginx/conf.d/domain.key; client_max_body_size 0;
chunked_transfer_encoding on;
location /v2/ {
if ($http_user_agent ~ "A(docker\/1\.(3i4|5(?!\.[0-9]-dev))!Go ),*$" ) {
return 404;
}
auth_basic "registry.localhost";
auth_basic_user_file /etc/nginx/conf.d/htpasswd;
add_header 'Docker-Distribution-Api-Version' 'registry/2.0' always;
proxy_pass
proxy_set_header IHost
proxy_set_header :X-Real-IP proxy_set_headerX:-Forwarded-For$proxy_add_x_forwarded_for; proxy_set_headerX:-Forwarded-ProtoSscheme;
proxy_read_timeout 900;
}
}
$ docker run -d --name nginx_frontend \
- p 443:443 \
--link myregistry:registry \
-v $(pwd)/certs/:/etc/nginx/conf.d \
nginx:1.9
-v
$ docker login https://${DOCKER_HOST_IP}
$ cp certs/ca.crt /usr/local/share/ca-certificates/
$ update-ca-certificates
$ service docker restart
$ docker start nginx_frontend
docker login
으로 인증 요청$ docker tag my-image-name:0.0 192.168.99.100/my-image-name:0.0
$ docker push 192.168.99.100/my-image-name:0.0
ℹ️ 개발자들이 미리 만들어놓은 레지스트리 제어 CLI 사용 가능
깃허브에서 docker registry cli 같은 키워드 검색