Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
# 키정보를 담을 경로 생성
[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 /root/certs/:/certs/ \
>  -e REGISTRY_HTTP_TLS_CERTIFICATE=/root/certs/server.cert \
>  -e REGISTRY_HTTP_TLS_KEY=/root/certs/server.key \
>  registry
Unable to find image 'registry:latest' locally
latest: Pulling from library/registry
c87736221ed0: Pull complete 
1cc8e0bb44df: Pull complete 
54d33bcb37f5: Pull complete 
e8afc091c171: Pull complete 
b4541f6d3db6: Pull complete 
Digest: sha256:3b00e5438ebd8835bcfa7bf5246445a6b57b9a50473e89c02ecc8e575be3ebb5
Status: Downloaded newer image for registry:latest
c049302e7dab29a15a948618787e0f21d7c006deb08f844f83aa5a9e805c9620
[root@spring2-vm ~]# 

# 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 /root/certs/* /etc/docker/certs.d/registry.thesanse.com:5000/
[root@spring2-vm ~]# cp /root/certs/server.cert /etc/docker/certs.d/registry.thesanse.com:5000/server.crt