# 키정보를 담을 경로 생성
[root@spring2-vm ~]# mkdir -p certs

# private key 생성
[root@spring2-vm ~]# openssl genrsa -des3 -out certs/server.key 2048
Generating RSA private key, 2048 bit long modulus
.............................................................................+++
...............+++
e is 65537 (0x10001)
Enter pass phrase for certs/server.key:
Verifying - Enter pass phrase for certs/server.key:
[root@spring2-vm ~]#
## private key 패스워드 : 1qazxsw23edC

# 키정보로 이동한후 인증서 요청파일 생성
[root@spring2-vm ~]# cd certs/
[root@spring2-vm certs]# 
[root@spring2-vm certs]# 
[root@spring2-vm certs]# 
[root@spring2-vm certs]# openssl req -new -key server.key -out server.csr
Enter pass phrase for server.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:KR
State or Province Name (full name) []:Seoul
Locality Name (eg, city) [Default City]:Seoul
Organization Name (eg, company) [Default Company Ltd]:Korea PE
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:registry.thesanse.com
Email Address []:sooabia@gmail.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@spring2-vm certs]# 
[root@spring2-vm certs]# 
[root@spring2-vm certs]# 

# private key에서 암호 제거 1qazxsw23edC
[root@spring2-vm certs]#  cp server.key server.key.origin
[root@spring2-vm certs]#  openssl rsa -in server.key.origin -out server.key
Enter pass phrase for server.key.origin:
writing RSA key
[root@spring2-vm certs]# 
[root@spring2-vm certs]#  rm server.key.origin 
rm: remove regular file 쁲erver.key.origin 
[root@spring2-vm certs]#

# 앞서만든 인증서 요청파일로 인증서 생성
[root@spring2-vm certs]# openssl x509 -req -days 730 -in server.csr -signkey server.key -out server.cert
Signature ok
subject=/C=KR/ST=Seoul/L=Seoul/O=Korea PE/OU=IT/CN=registry.thesanse.com/emailAddress=sooabia@gmail.com
Getting Private key
[root@spring2-vm certs]# 
[root@spring2-vm certs]# 

# docker registry 시작
[root@spring2-vm ~]# docker run -d -p 5000:5000 --restart=always --name docker-registry \
>  -v /certs/:/certs/ \
>  -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server.cert \
>  -e REGISTRY_HTTP_TLS_KEY=/certs/server.key \
>  registry
 12c9d6f2d151fdf55c7c20422a5a9890fce1cfdd89ff2e3fcec28437ddd60160

# self-signed 인증서이기 때문에 아래 파일을 복사해 주어야 합니다.
[root@spring2-vm ~]# mkdir -p /etc/docker/certs.d/registry.thesanse.com:5000/
[root@spring2-vm ~]# 
[root@spring2-vm ~]# 
[root@spring2-vm ~]# cp /certs/* /etc/docker/certs.d/registry.thesanse.com:5000/
[root@spring2-vm ~]# cp /certs/server.cert /etc/docker/certs.d/registry.thesanse.com:5000/server.crt
[root@spring2-vm ~]#
[root@spring2-vm ~]#

# Push 할 이미지 준비
[root@spring2-vm ~]# docker pull hello-world
[root@spring2-vm ~]# docker tag hello-world:latest registry.thesanse.com:5000/hello-world:latest
[root@spring2-vm ~]# 

# Private Registry 에 이미지 Push
[root@spring2-vm ~]# docker push registry.thesanse.com:5000/hello-world:latest 
The push refers to repository [registry.thesanse.com:5000/hello-world]
af0b15c8625b: Pushed 
latest: digest: sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a size: 524
[root@spring2-vm ~]# 
  • No labels
Write a comment…