[DevOps - CentOS 7.9] Docker Remote Registry ์‚ฌ์šฉ๋ฒ•

2022. 11. 16. 23:09ใ†System ์ž‘์—…์‹ค/Docker

728x90
๋ฐ˜์‘ํ˜•

 




๐Ÿ—‚ ๋ชฉ์ฐจ

โ— [DevOps - CentOS 7.9] Docker Local Registry (๊ฐœ์ธ Docker Hub) ๊ตฌ์ถ•ํ•˜๊ธฐ 
โ— [DevOps - CentOS 7.9] Docker Local Registry ์‚ฌ์šฉ๋ฒ•
โ— [DevOps - CentOS 7.9] Docker Remote Registry ์‚ฌ์šฉ๋ฒ•

 



๐Ÿš€ ์›๊ฒฉ์ง€ Docker Hub ์„ค์ •

    ๐Ÿ”ฝ  ๊ฐœ์š”

        ๐Ÿ“ฆ ์ค€๋น„ํ•˜๊ธฐ

์œ„์˜ ๋ฐฉ๋ฒ•์€ Local Docker Image๋ฅผ Pushํ•˜๊ณ , Pullํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์ด์—์š”.

๋งŒ์•ฝ Resistry๊ฐ€ ์›๊ฒฉ์ง€์— ์žˆ๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค์ •์„ ํ•ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์ตœ์ดˆ ์›๊ฒฉ์ง€์— ๋Œ€ํ•œ ์„ค์ •์„ ํ•˜๊ธฐ ์œ„ํ•ด์„œ SSL/TLS ํ†ต์‹ ์ด ๊ฐ€๋Šฅํ•˜๋„๋ก ํ•ด ์ฃผ์–ด์•ผ ํ•ด์š”.
์ด ๋•Œ๋ฌธ์— SSL/TLS ์ธ์ฆ์„œ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์–ด์•ผ ํ•˜๋Š”๋ฐ, ์ด ๋ถ€๋ถ„์— ๋Œ€ํ•ด์„œ๋Š” ์ด ๊ณณ์— ์ค€๋น„ํ•ด ๋‘์—ˆ์–ด์š”.

์ค€๋น„ํ•œ ์ •๋ฆฌ ๋ถ€๋ถ„์—์„œ SSL/TLS ์ธ์ฆ์„œ๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์œผ๋‹ˆ ์ด์ œ ์ ์šฉ์„ ์‹œ์ผœ ๋ณผ๊ฒŒ์š”.

์ตœ์ดˆ Server์—์„œ ์ƒ์„ฑ๋œ ์ธ์ฆ์„œ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” Registry Container๋ฅผ ์žฌ ์‹œ์ž‘ํ•ด์ฃผ์–ด์•ผ ํ•ด์š”.

๋งŒ์•ฝ Registry๊ฐ€ ๊ธฐ๋™์ค‘์ด๋ผ๋ฉด ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด Container๋ฅผ ์ค‘์ง€ํ•˜๊ณ , ์‚ญ์ œํ•ด ์ฃผ์„ธ์š”.

docker stop {Container ID}			// Container ์ค‘์ง€
docker rm {Container ID}			// Container ์‚ญ์ œ



docker ps -a


์ตœ์ดˆ ์ฃผ๋‹ˆํ•˜๋ž‘์€ Docker Registry๋ฅผ Web์œผ๋กœ ๋ณด์—ฌ์ฃผ๋Š” Container๋ถ€ํ„ฐ ๋‚ด๋ฆฌ๊ณ , ์—†์• ๋ฒ„๋ ธ์–ด์š”.

์ด Container๋„ Docker Registry์— ์ข…์†ํ•ด์„œ ๊ธฐ๋™์ค‘์ด๊ธฐ ๋•Œ๋ฌธ์ด์—์š”.



๊ทธ๋Ÿฐ ๋’ค Docker Registry Container๋„ ๋‚ด๋ฆฌ๊ณ , ์—†์•  ๋ฒ„๋ ธ์–ด์š”.



 

    ๐Ÿ”ฝ  ์ธ์ฆ์„œ ์ ์šฉ

        ๐Ÿ“ฆ Docker Registry

์ด์ œ ์ธ์ฆ์„œ๋ฅผ ์ ์šฉํ•˜๊ณ , Container๋ฅผ ์žฌ ๊ธฐ๋™ ํ•ด ๋ณผ๊ฒŒ์š”.

 

docker ๊ธฐ๋™ ๋ช…๋ น์–ด

docker run -itd \
--restart=always \
--name={Container Name} \
--ip {Container IP} \
-v {์ธ์ฆ์„œ ๋งŒ๋“  Sever์˜ ์ธ์ฆ์„œ Directory Path}:{Container ๋‚ด๋ถ€ ์ธ์ฆ์„œ ๋ณด๊ด€ํ•  Directory} \
-v /opt/docker/volume_mapping/registry:/var/lib/registry/docker/registry/v2 \
-e REGISTRY_HTTP_ADDR=0.0.0.0:5000 \
-e REGISTRY_HTTP_TLS_CERTIFICATE={Container ๋‚ด๋ถ€ ์ธ์ฆ์„œ ๋ณด๊ด€ํ•  Directory}/server.crt \
-e REGISTRY_HTTP_TLS_KEY={Container ๋‚ด๋ถ€ ์ธ์ฆ์„œ ๋ณด๊ด€ํ•  Directory}/server.key -p 5000:5000 \
registry:latest



์ฃผ๋‹ˆํ•˜๋ž‘์€ ์œ„์™€ ๊ฐ™์ด Docker๋ฅผ ๊ธฐ๋™ ์‹œ์ผœ ์ฃผ์—ˆ์–ด์š”.


docker ps -a && docker logs {Container ID}


์ผ๋‹จ ์œ„์™€ ๊ฐ™์ด Container๊ฐ€ ๊ธฐ๋™ ์ค‘์ธ๊ฑธ ํ™•์ธํ•˜์˜€์–ด์š”.

 

 

 

 

 

 

 

        ๐Ÿ“ฆ Jenkins

์ฃผ๋‹ˆํ•˜๋ž‘์ด ํ™œ๋™ํ•˜๊ณ  ์žˆ๋Š” ๊ฐœ๋ฐœ ํ”„๋กœ์ ํŠธ ๊ธฐ๊น”๋‚˜๋Š” ์‚ฌ๋žŒ๋“ค์€ CI/CD๋ฅผ ์œ„ํ•ด Jenkins์™€ Docker๋ฅผ ์ด์šฉํ•˜๊ณ  ์žˆ๊ณ , ์ฃผ๋‹ˆํ•˜๋ž‘์€ Docker Image๋ฅผ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ Docker Registry๋ฅผ ๋งŒ๋“ค๊ณ  ์žˆ์–ด์š”.

Docker Registry์— push๋ฅผ ํ•˜๊ณ ์ž ํ•˜๋Š” Client์—์„œ๋„ SSL/TLS ์ธ์ฆ์„œ๋ฅผ ์ ์šฉ ์‹œ์ผœ์•ผ ํ•˜๋Š” ์ž‘์—…์ด ํ•„์š”ํ•ด์š”.

๊ธฐ๊น”๋‚˜๋Š” ์‚ฌ๋žŒ๋“ค์€ Jenkins๋ฅผ ์ด์šฉํ•ด์„œ Docker Registry์— Image๋ฅผ ๊ด€๋ฆฌํ•  ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— Jenkins์— SSL/TLS๋ฅผ ์ ์šฉ ์‹œ์ผœ ๋ณด๋ ค๊ณ  ํ•ด์š”.

๊ทธ๋Ÿฌ๊ธฐ ์ „์— Docker Host Server ์ฆ‰, SSL/TLS ์ธ์ฆ์„œ๋ฅผ ๋งŒ๋“  Server์—์„œ๋„ Docker Registry๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •ํ•ด ๋ณผ๊ฒŒ์š”.

ํ•ด๋‹น Server๋Š” ๊ฐ€์ƒ OS์ด๋ฉฐ, CentOS 7.9 ์ž…๋‹ˆ๋‹ค.

cp {์ธ์ฆ์„œ ์ ˆ๋Œ€ ๊ฒฝ๋กœ}/{์ธ์ฆ์„œ ์ด๋ฆ„}.crt /etc/pki/ca-trust/source/anchors/


๋จผ์ € ์ธ์ฆ์„œ๋ฅผ ์œ„์˜ ์œ„์น˜๋กœ ๋ณต์‚ฌ ๋ถ™ํ˜€๋„ฃ๊ธฐ ํ•˜์—ฌ ์ฃผ์—ˆ์–ด์š”.

update-ca-trust


๊ทธ๋Ÿฐ ๋’ค ์œ„์˜ ๋ช…๋ น์–ด๋กœ ์ธ์ฆ์„œ ์ตœ์‹ ํ™” ํ•˜์—ฌ ์ฃผ์—ˆ์–ด์š”.


systemctl restart docker && systemctl status docker


๊ทธ๋Ÿฐ ๋’ค Docker Deamon์„ ์žฌ ๊ธฐ๋™ ํ•˜์—ฌ ์ฃผ์—ˆ์–ด์š”.



์ด๋ฒˆ์—๋Š” Jenkins์—์„œ ์ž‘์—…์„ ํ•ด ์ค„๊ฒŒ์š”.

์ตœ์ดˆ SCP(Secure Copy)๋ฅผ ์ด์šฉํ•˜์—ฌ Docker Registry Container์—
๋„ฃ์–ด์ฃผ์—ˆ๋˜ ์ธ์ฆ์„œ๋ฅผ Jenkins์— ์˜ฎ๊ฒจ์ฃผ๋„๋ก ํ•  ๊ฑฐ์—์š”.

Jenkins ์—ญ์‹œ Docker Container๋กœ ๊ธฐ๋™ ์ค‘์ด๋ฉฐ, 

cat /etc/issue


OS ์ข…๋ฅ˜๋Š” ์œ„์™€ ๊ฐ™์ด Debian ๊ณ„์—ด์ด์—์š”.


apt-get update && apt-get upgrade -y


SCP๋ฅผ ์ด์šฉํ•ด์„œ File์„ ์ „์†กํ•˜๋ ค๋ฉด SSH Deamon์ด ๊ธฐ๋™ ์ค‘์ด์—ฌ์•ผ ํ•ด์š”.

Openssh Server๋ฅผ ๊ธฐ๋™ํ•˜๊ธฐ ์œ„ํ•ด ํ•ด๋‹น ์„ค์น˜ File์„ ๋‚ด๋ ค ๋ฐ›์„ ๊ฑด๋ฐ, ๊ทธ ์ „์— apt๋ฅผ Update ํ•ด ์ฃผ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.


apt-get install -y openssh-server


๊ทธ๋Ÿฐ ๋’ค ์œ„์™€ ๊ฐ™์ด openssh Package๋ฅผ ๋‚ด๋ ค ๋ฐ›์•„ ์ค„๊ฑฐ์—์š”.


/etc/init.d/ssh start


๊ทธ๋Ÿฐ ๋’ค ์œ„์™€ ๊ฐ™์ด ssh Deamon์„ ๊ธฐ๋™ ์‹œ์ผœ ์ค๋‹ˆ๋‹ค.


netstat -ntl



22๋ฒˆ Port๋ฅผ ์‚ฌ์šฉํ•˜๋Š” SSH๊ฐ€ Listen ์ƒํƒœ ์ธ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.

 

passwd


SSH, SCP ๋“ฑ์„ ํ†ตํ•ด ํ•ด๋‹น Server์— ์ ‘์†ํ•˜๋ ค๋ฉด ์ ‘์†ํ•˜๊ณ ์ž ํ•˜๋Š” ๊ณ„์ •์— ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์„ค์ • ๋˜์–ด ์žˆ์–ด์•ผ ํ•ด์š”.
์ฃผ๋‹ˆํ•˜๋ž‘์€ ์œ„์™€ ๊ฐ™์ด Root ๊ณ„์ •์— Password๋ฅผ ์„ค์ •ํ•ด ์ฃผ์—ˆ์–ด์š”.


scp -r {๋Œ€์ƒ Server ๊ณ„์ •}@{๋Œ€์ƒ Server IP}:~/{๋Œ€์ƒ Server Directory Path} {๋‚ด๋ ค ๋ฐ›๊ณ ์ž ํ•˜๋Š” Server Path}

๋ฐ˜์‘ํ˜•


์œ„์™€ ๊ฐ™์ด scp ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด Directory ์ž์ฒด๋ฅผ ๋‚ด๋ ค ๋ฐ›์•„ ์ฃผ์—ˆ์–ด์š”.



Debian ๊ณ„์—ด์˜ ๊ฒฝ์šฐ ์œ„์™€ ๊ฐ™์ด ์ธ์ฆ์„œ๋ฅผ ๋“ฑ๋กํ•ด ์ฃผ์–ด์•ผ ํ•ด์š”.

์œ„์™€ ๊ฐ™์ด ๋“ฑ๋ก์„ ํ•ด ์ฃผ์—ˆ๋‹ค๋ฉด Server ์žฌ ๊ธฐ๋™์„ ํ•ด ์ค๋‹ˆ๋‹ค.


docker restart {Container ID}


์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด Docker Container๋ฅผ ์žฌ ๊ธฐ๋™ ํ•  ์ˆ˜ ์žˆ์–ด์š”.










    ๐Ÿ”ฝ  ๊ฐ€์ง€๊ณ  ๋†€๊ธฐ

        ๐Ÿ“ฆ Test

์ด์ œ ์ž˜ ๋˜๋Š”์ง€ ํ•œ๋ฒˆ ํ™•์ธํ•ด ๋ณผ๊นŒ์š”?

Test๋Š” Jenkins Docker๊ฐ€ ์•„๋‹Œ Docker Container Host Server์—์„œ ์ง„ํ–‰ํ•˜๋„๋ก ํ•  ๊ฒƒ์ด์—์š”.


docker pull hello-world


์ตœ์ดˆ Test๋ฅผ ์œ„ํ•ด hello-world Docker Image๋ฅผ ๋ฐ›์•„ ์ฃผ์—ˆ์–ด์š”.


docker tag {Image ์ด๋ฆ„} {Registry IP}:{Port}/{Container ์ด๋ฆ„}


์œ„์™€ ๊ฐ™์ด Tag ์ •๋ณด๋ฅผ ๋‚จ๊ฒจ์„œ docker Image๋ฅผ ์ƒˆ๋กœ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์–ด์š”.

์ค‘์š”ํ•œ ๊ฑด Image ์ด๋ฆ„์— Docker Registry ์ •๋ณด๊ฐ€ ๊ผญ ๋“ค์–ด๊ฐ€์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์ด์—์š”.


docker push {Registry IP}:{Port}/{Container ์ด๋ฆ„}


์œ„์™€ ๊ฐ™์ด Registry์— push ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด Image๋ฅผ ๋“ฑ๋กํ•ด ์ฃผ์—ˆ์–ด์š”.


curl -v -k -X GET https://{Registry IP}:{Port}/v2/_catalog


์œ„์™€ ๊ฐ™์ด repositories์— registry-test Image๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๋“ค์–ด๊ฐ„ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.


์ด๋ฒˆ์—๋Š” Resistry Web Service๋ฅผ ๊ธฐ๋™ํ•˜์—ฌ ๋ณด๋‹ค ํŽธํ•˜๊ฒŒ ํ™•์ธํ•ด ๋ณผ๊ฒŒ์š”.



hyper/docker-registry-web์— ๋Œ€ํ•œ ์„ค์ •์€ ์ด ๊ณณ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.




๊ธฐ๋™์€ ์ž˜ ๋˜์—ˆ์ง€๋งŒ, ์œ„์™€ ๊ฐ™์ด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ์–ด์š”.

๊ธฐ์กด์— ์ฃผ๋‹ˆํ•˜๋ž‘์€ Resistry์™€ Web Service๋ฅผ ์—ฐ๊ฒฐํ•  ๋•Œ, yml File์„ ์•„๋ž˜์™€ ๊ฐ™์ด ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์–ด์š”.


docker_registry_config.yml


์ฆ‰, ํ˜„์žฌ๋Š” https SSL/TLS ๋ฐฉ์‹์œผ๋กœ ํ†ต์‹ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— http๋กœ ์š”์ฒญ์„ ๋ณด๋‚ด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค๋Š” ๊ฒƒ์ด์—์š”.


vim /opt/docker/config/docker_registry_config.yml


์œ„์™€ ๊ฐ™์ด ์ˆ˜์ •์„ ํ•ด์ฃผ๊ณ , Web ๊ด€๋ จ Container๋ฅผ ์ฃฝ์˜€๋‹ค๊ฐ€ ๋‹ค์‹œ ๊ธฐ๋™ ์‹œ์ผœ ๋ณผ๊ฒŒ์š”.


728x90
docker run -it \
--ip 172.17.0.5 \
-d --restart=always \
-p 8081:8080 \
--name Giggal-people_DockerHub \
--link Giggal-people_Docker-Hub \
-v /opt/docker/config/docker_registry_config.yml:/conf/config.yml:ro \
hyper/docker-registry-web




์œ„์™€ ๊ฐ™์ด ๋‹ค์‹œ ์˜ฌ๋ ค ์ฃผ์—ˆ์–ด์š”.



curl -X GET {Registry IP}:{Port}/v2/_catalog


์œ„์™€ ๊ฐ™์ด curl์„ ์ด์šฉํ•ด์„œ HTTP Method Get์œผ๋กœ ์ž˜ ๋“ค์–ด๊ฐ”๋Š”์ง€ ํ™•์ธํ•˜๊ณ ์ž ํ•˜์˜€์œผ๋‚˜,
์ธ์ฆ์„œ ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.

 

curl -v -X GET curl -X GET {Registry IP}:{Port}/v2/_catalog


-v Option์„ ์ถ”๊ฐ€ํ•˜์—ฌ ์ž์„ธํ•˜๊ฒŒ ๋ฌด์Šจ ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ ค๊ณ  ํ–ˆ์–ด์š”.

์ด ๋ฌธ์ œ๋Š” ๋ฐœ๊ธ‰์ž ์ธ์ฆ์„œ๊ฐ€ ์œ ํšจํ•˜์ง€ ์•Š๋‹ค๋Š” ๋ฌธ์ œ์—์š”.

์ฃผ๋‹ˆํ•˜๋ž‘์€ crt File์„ ~/certificate/server.crt์— ์ €์žฅ์„ ํ•ด ์ฃผ์—ˆ๋Š”๋ฐ, ์œ„์— curl์—์„œ ๋ณด๋ฉด ํ•ด๋‹น CA File์„ /etc/pki/tls/certs/ca-bundle.crt๋กœ ์ฐธ์กฐํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.

"์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค."


์ตœ์ดˆ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ๊ธฐ์กด์— ์ €์žฅ๋˜์–ด ์žˆ๋˜ ca-bundle.crt๋ฅผ ๋”ฐ๋กœ ์ €์žฅํ•ด ๋‘๊ณ , ์ฃผ๋‹ˆํ•˜๋ž‘์ด ๋งŒ๋“  server.crt ๋ผ๋Š” File์„ /etc/pki/tls/certs/ca-bundle.crt๋กœ ๋ฎ์–ด์“ฐ๊ธฐ ํ•ด ์ฃผ์—ˆ์–ด์š”.

๊ทธ๋Ÿฐ ๋’ค ๋‹ค์‹œ curl ๋ช…๋ น์–ด๋ฅผ ์ˆ˜ํ–‰ํ•˜๋‹ˆ ์ •์ƒ์ ์œผ๋กœ ์ž‘๋™ํ•˜๋Š” ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ์–ด์š”.

๊ทธ๋ ‡๋‹ค๋ฉด ์œ„์™€ ๊ฐ™์ด Docker Registry์™€ ํ†ต์‹ ํ•ด์•ผ ํ•˜๋Š” ๋ชจ๋“  Server๋“ค์— ํ•ด๋‹น ์ž‘์—…์ด ํ•„์š”ํ•˜๋‹ค๋Š” ๊ฑธ ๊นจ๋‹ฌ์•˜์–ด์š”. 


๋จผ์ € Docker Registry Web Server์—์„œ ์ž‘์—…์„ ํ•ด ๋ณผ๊ฒŒ์š”.

docker exec -it {Container ID} /bin/bash


์ตœ์ดˆ Bash Shell์„ ์ด์šฉํ•˜๊ฒ ๋‹ค๊ณ  ์•Œ๋ ค์ฃผ๋ฉด์„œ ํ•ด๋‹น Container์— ์ ‘์†ํ•˜์—ฌ ์ค„๊ฒŒ์š”.

curl์ด ์„ค์น˜๋˜์–ด ์žˆ์ง€ ์•Š์œผ๋ฏ€๋กœ ์„ค์น˜๋ฅผ ํ•ด์ค„๊ฒŒ์š”.

cat /etc/issue


ํ•ด๋‹น Container๋Š” Ubunt 14.04.5 LTS ์—์„œ ๊ธฐ๋™์ค‘์ด๋‹ˆ ๊ทธ์— ๋งž๋Š” ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ด์š”.


apt-get update && apt-get upgrade -y


์ตœ์ดˆ apt๋ฅผ ์ตœ์‹ ํ™” ํ•ด์ค„๊ฒŒ์š”.


apt-get install -y curl


๊ทธ๋Ÿฐ ๋’ค ์œ„์™€ ๊ฐ™์ด curl์„ ๋‚ด๋ ค ๋ฐ›์•„ ์ฃผ์—ˆ์–ด์š”.


curl -v -X https://{Docker Registry IP}:{Port}/v2/_catalog


์—ญ์‹œ ์œ„์™€ ๊ฐ™์ด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๊ณ  ์žˆ์–ด์š”.



SCP ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด์„œ ์œ„์—์„œ ์ €์žฅํ•ด๋‘” File์„ ๋ฐ”๋กœ ๋ฐ›์•„์˜ค๋„๋ก ํ–ˆ์–ด์š”.

update-ca-certificats


๊ทธ๋Ÿฐ ๋‹ค์Œ ์œ„์— ๋ช…๋ น์–ด๋กœ ์ธ์ฆ์„œ๋ฅผ ์ตœ์‹ ํ™” ํ•ด ์ฃผ์—ˆ์–ด์š”.


curl -v -X GET https://{Docker Registry IP}:{Port}/v2/_catalog


์ •์ƒ์ ์œผ๋กœ ์—ฐ๊ฒฐ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.



๋งˆ์ง€๋ง‰์œผ๋กœ Jenkins๋„ ์ž‘์—…ํ•ด ์ค˜์•ผ๊ฒ ์–ด์š”.

curl -v -X GET https://172.17.0.2:5000/v2/_catalog


์œ„์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๊ณ  ์žˆ๋Š”๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.



์œ„์™€ ๊ฐ™์ด crt File์„ SCP๋กœ ์ด์šฉํ•ด์„œ ๋‚ด๋ ค ๋ฐ›์€ ๋’ค ์ธ์ฆ์„œ ์ตœ์‹ ํ™”๋ฅผ ํ•ด์ฃผ์—ˆ์–ด์š”.




๋Œ€์ƒ Server๊ฐ€ ๊ฐ€์ง„ ์ธ์ฆ์„œ๋ฅผ ์ง์ ‘ Handlingํ•˜๊ธฐ ์œ„ํ•ด ์œ„์™€ ๊ฐ™์ด ๋‚ด๋ ค ๋ฐ›๊ธฐ๋ฅผ ํ•ด ์ฃผ์—ˆ์–ด์š”.


vim /etc/ssl/certs/cacert.pem


pem File์„ ์ˆ˜์ •ํ•ด์•ผ ํ•˜๋Š”๋ฐ, ์œ„์™€ ๊ฐ™์ด ---BEGINS CERTIFICATE--- ๋ถ€ํ„ฐ ---END CERTIFICATE---- ๊นŒ์ง€๋งŒ ๋‚จ๊ธฐ๊ณ  ๋ชจ๋‘ ์ง€์›Œ์ฃผ์„ธ์š”. ๋งŒ์•ฝ ์ด ๋‚ด์šฉ์ด ๋‘ ๊ฐœ๋ผ๋ฉด ๋งจ ์•„๋ž˜ ๋ถ€๋ถ„๋งŒ ๋‚จ๊ธฐ๊ณ , ๋ชจ๋‘ ์ง€์›Œ์ค๋‹ˆ๋‹ค.


cat cacert.pem > /usr/local/share/ca-certificates/cacert.crt


์ˆ˜์ •ํ•œ pem File์„ cacert.crt๋กœ ๋ณ€ํ™˜ํ•ด์„œ ์ €์žฅํ•ด ์ฃผ๊ณ , ์ธ์ฆ์„œ Update๋ฅผ ์ง„ํ–‰ํ•ด ์ฃผ์—ˆ์–ด์š”.

root@319ae9040b13:/etc/ssl/certs# curl -v -X GET https://172.17.0.2:5000/v2/_catalogNote: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 172.17.0.2:5000...
* Connected to 172.17.0.2 (172.17.0.2) port 5000 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=KO; L=Default City; O=Giggal-people; CN=172.17.0.2; emailAddress=giggals.pepole@gmail.com
*  start date: Nov 17 04:38:24 2022 GMT
*  expire date: Nov 16 04:38:24 2025 GMT
*  subjectAltName: host "172.17.0.2" matched cert's IP address!
*  issuer: C=KO; L=Default City; O=Giggal-people; CN=172.17.0.2; emailAddress=giggals.pepole@gmail.com
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x5631f71f91e0)
> GET /v2/_catalog HTTP/2
> Host: 172.17.0.2:5000
> user-agent: curl/7.74.0
> accept: */*
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 200 
< content-type: application/json; charset=utf-8
< docker-distribution-api-version: registry/2.0
< x-content-type-options: nosniff
< content-length: 35
< date: Thu, 17 Nov 2022 10:19:53 GMT
< 
{"repositories":["registry-test"]}
* Connection #0 to host 172.17.0.2 left intact


์œ„์™€ ๊ฐ™์ด ์ •์ƒ์ ์œผ๋กœ Curl์„ ํ†ตํ•ด ํ†ต์‹ ์ด ๋œ ๊ฒƒ์„ ํ™•์ธํ•˜์˜€์–ด์š”.



Docker Web Registry


์•ˆํƒ€๊น๊ฒŒ๋„ Web Registry๋Š” ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์„ ๊ฑฐ ๊ฐ™์•„์š”.

์œ„์—์„œ ๋‚˜์˜ค๋Š” ๋ฌธ์ œ๋Š” JAVA์—์„œ SSL ํ†ต์‹ ์„ ํ•˜์ง€ ๋ชปํ•˜์—ฌ ๋ฐœ์ƒํ•˜๋Š” Exception์ธ๋ฐ, ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ์œ„์—์„œ์™€ ๊ฐ™์ด Server๋‚ด์—์„œ ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ๋“ค์„ ํ•ด๋ณด์•˜์ง€๋งŒ, JAVA์—์„œ TLS Version ๋“ฑ์— ์„ค์ •์ด ํ•„์š”ํ•  ๊ฑฐ ๊ฐ™์•„์š”.

ํ˜น์‹œ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ์•„์‹œ๋Š” ๋ถ„์ด ๊ณ„์‹œ๋‹ค๋ฉด ๋Œ“๊ธ€ ๋ถ€ํƒ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค! ๐Ÿซก








๐Ÿง ์ฐธ๊ณ  ์ž๋ฃŒ

 

[linux] Self-signed certificate ๋ฅผ ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ๋Š” ์ธ์ฆ์„œ๋กœ ์ถ”๊ฐ€ํ•˜๊ธฐ

๊ฐœ์š” ์‚ฌ๋‚ด๋ง์˜ ํ”„๋ฝ์‹œ ์„œ๋ฒ„๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ์„ค SSL ์ธ์ฆ์„œ๋กœ ์ธํ•˜์—ฌ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ํฌํ•จํ•œ ๊ฐ์ข… ๋„คํŠธ์›Œํฌ ๋„๊ตฌ (curl, wget ๋“ฑ)๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค. ํ•ด๋‹น ๋ฌธ์ œ๋Š” ๋ธŒ๋ผ์šฐ์ €๋ฅผ ํฌ

rottk.tistory.com

 

 

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•