반응형

 

 

 

Docker에서 기본 인증 사용하기

도커 레지스트리에는 로그인 기능이 없기 때문에 Nginx의 기본인증 기능을 사용해야하며, HTTP 프로토콜에는 인증을 지원하지 않습니다. 따라서 HTTPS 프로토콜을 사용해야합니다.

 

 

 

/etc/hosts 파일 수정

# vi /etc/hosts
127.0.0.1 localhost
127.0.1.1 master
192.168.0.201 registry.example.com


# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

 

 

 

 

사설 SSL 인증서 생성 및 설정

# openssl genrsa -out server.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
.......................................+++++
..................................+++++
e is 65537 (0x010001)

 

 

사설 SSL 인증서 키 파일 설정

# openssl req -new -key server.key -out server.csr
Can't load /root/.rnd into RNG
139832043372992:error:2406F079:random number generator:RAND_load_file:Cannot open file:../crypto/rand/randfile.c:88:Filename=/root/.rnd
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) [AU]:KO
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:Seoul
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Company
Organizational Unit Name (eg, section) []:Company
Common Name (e.g. server FQDN or YOUR name) []:registry.example.com
Email Address []:jinsu@example.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
  • Country Name : 국가 코드이며, 대문자 KO를 입력합니다.
  • State or Province Name : 주 또는 도입니다. 상황에 맞게 입력
  • Locality Name : 도시입니다. 상황에 맞게 입력
  • Organization Name : 회사이름 입력
  • Organizational Unit Name : 회사 조직 이름 입력
  • Common Name : Docker 레지스트리를 실행하는 서버의 도메인 주소 /etc/hosts 파일에 설정한대로 입력
  • Email Address : 이메일 주소 입력

 

 

 

서버 인증서 파일을 생성하고 시스템에 설치

# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt   
Signature ok
subject=C = KO, ST = Some-State, L = Seoul, O = Company, OU = Company, CN = registry.example.com, emailAddress = jinsu@example.com
Getting Private key

# ls
total 68
-rw-r--r--  1 root root 1350 Oct 30 07:23 server.crt
-rw-r--r--  1 root root 1070 Oct 30 07:23 server.csr
-rw-------  1 root root 1675 Oct 30 07:05 server.key

# cp server.crt /usr/share/ca-certificates/
# echo "server.crt" | tee -a /etc/ca-certificates.conf
server.crt
# update-ca-certificates 
Updating certificates in /etc/ssl/certs...
rehash: warning: skipping ca-certificates.crt,it does not contain exactly one certificate or CRL
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.

# service docker restart

 

 

 

 

이어서...

반응형

+ Recent posts