[DevOps - CentOS 7.9] Docker Local Registry (๊ฐœ์ธ Docker Hub) ๊ตฌ์ถ•ํ•˜๊ธฐ

2022. 11. 16. 17:07ใ†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 Registry ๊ตฌ์ถ•ํ•˜๊ธฐ

    ๐Ÿ”ฝ  ๊ฐœ์š”

์ฃผ๋‹ˆํ•˜๋ž‘์€ ๊ธฐ๊น”๋‚˜๋Š” ์‚ฌ๋žŒ๋“ค์ด๋ผ๋Š” Side Project ์ผ์›์œผ๋กœ ์šฐ๋ฆฌ๊ฐ€ ๊ฐœ๋ฐœํ•˜๊ณ , ์‹ค์ œ Service์— ์ด์šฉํ•  Docker Container๋ฅผ ๋ณด๋‹ค ์•ˆ์ „ํ•˜๊ฒŒ ๊ด€๋ฆฌํ•˜๊ณ  ์‹ถ์—ˆ์–ด์š”.

Docker Hub๋Š” Private์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋‹จ ํ•œ๊ฐ€์ง€ Repository ๋ฐ–์— ์ด์šฉํ•  ์ˆ˜ ์—†์—ˆ๊ณ , ์šฐ๋ฆฌ๋ผ๋ฆฌ ์•ˆ์ „ํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” Docker Hub๋ฅผ ์ฐพ๋‹ค๊ฐ€ Docker Registry๋ผ๋Š” ๊ฒƒ์„ ์ฐพ๊ฒŒ ๋˜์–ด ๊ตฌ์ถ•์„ ํ•ด๋ณด๋ ค๊ณ  ํ•ด์š”.





        ๐Ÿ“ฆ ๊ตฌ์ถ•ํ™˜๊ฒฝ

Host PC
โˆ™ OS ์ •๋ณด

uname -a

 

cat /etc/*release*



โˆ™ Hardware ์ •๋ณด

CPU ์ƒ์„ธ ์ •๋ณด : lscpu



System Info : dmidecode -t system



Memory Info : dmidecode -t memory

 

CPU Info : dmidecode -t processor



Virtual Machine
โˆ™ VM Application

CentOS Virtual Machine Manager



โˆ™ VM
  - OS ์ •๋ณด

 

cat /etc/*release*






  - Hardware ์ •๋ณด

CPU Info : lscpu

 

System Info : deidecode -t system

 

Memory Info : demidecode -t memory



CPU Info : dmidecode -t processor








Application

docker --version

 

docker-compose --version



 

 

    ๐Ÿ”ฝ  Docker Registry

        ๐Ÿ“ฆ ์„ค์น˜

์ตœ์ดˆ Docker Image๋ฅผ Pull ํ•˜์—ฌ ์ค„ ๊ฑฐ์—์š”.

docker pull registry:latest


์ตœ์‹  Version์— Docker registry๋ฅผ ๋ฐ›์•„ ์ฃผ์—ˆ์–ด์š”.


docker images registry


Image๊ฐ€ ์ž˜ ๋ฐ›์•„์ง„ ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.


 

docker run -it \
--name Giggal-people_Docker-Hub \
--ip {Container ํ• ๋‹น IP} \
-d --restart=always \
-p 5000:5000 \
-v /opt/docker/volume_mapping/registry:/var/lib/registry/docker/registry/v2 \
registry:latest


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

Option ์„ค     ๋ช…
--name ๊ธฐ๋™ํ•  Docker Container ์ด๋ฆ„ ์ง€์ •
-d Container ๊ธฐ๋™ Back Ground๋กœ ์‹คํ–‰
-p Host PC์™€ Port Mapping
(Host Port : Container Port)
-v Host PC์™€ Volume Mapping
(Host PC Volume Path : Container Volume Path)
--restart=always Host PC๊ฐ€ ์žฌ๋ถ€ํŒ… ๋˜๋ฉด ์ž๋™์œผ๋กœ ํ•ด๋‹น Container ๊ธฐ๋™
--ip ๊ณ ์ • IP ํ• ๋‹น
๋ฐ˜์‘ํ˜•
๐Ÿ’ก ์ฐธ๊ณ  ์‚ฌํ•ญ
โˆ™ Docker Registry Volume ๊ด€๋ฆฌ
Docker Container๋กœ Registry๋ฅผ ๊ตฌ์ถ•ํ•  ๊ฒฝ์šฐ Registry Container๊ฐ€ Down ๋œ๋‹ค๋ฉด Container์˜ ์ •๋ณด๋Š” ํœ˜๋ฐœ์„ฑ์ด๊ธฐ ๋•Œ๋ฌธ์— ์„ค์ •ํ•œ ๋ชจ๋“  ๋‚ด์šฉ์ด ์‚ฌ๋ผ์ง„๋‹ค.
์ด๋ฅผ ๋ฐฉ์–ดํ•˜๊ธฐ ์œ„ํ•ด Volume Mapping ์ „๋žต์„ ์‚ฌ์šฉํ•˜์—ฌ Container ์„ค์ • ์ •๋ณด๊ฐ€ Host PC์— ๋‚จ๊ฒŒ ์„ค์ •ํ•ด ์ค€๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด Container ์žฌ ๊ธฐ๋™์‹œ ์ž๋™์œผ๋กœ ํ•ด๋‹น ์ •๋ณด๋ฅผ ๊ฐ€์ ธ๊ฐ€๊ฒŒ ๋œ๋‹ค.

 

docker container ls


registry Docker๊ฐ€ ๊ธฐ๋™ ์ค‘์ธ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.

 

 

 

    ๐Ÿ”ฝ  Docker Registry Dashboard

        ๐Ÿ“ฆ Web Service ๊ตฌ์ถ• 

์ด๋ฒˆ์—๋Š” ์šฐ๋ฆฌ ํฌ๋ฃจ๋“ค์ด ๋ณด๋‹ค ํŽธ๋ฆฌํ•˜๊ฒŒ Container๋“ค์„ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก Web Service์—์„œ ๋‚ด์šฉ๋“ค์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌ์ถ•ํ•ด ๋ณผ๊ฒŒ์š”.

์ตœ์ดˆ Docker-Registry-Web์„ ์„ค์น˜ํ•˜๊ธฐ ์œ„ํ•ด yml File์„ ์ž‘์„ฑํ•ด ์ฃผ์–ด์•ผ ํ•ด์š”.


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


yml์„ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•ด Docker Registry์˜ IP๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ถ€๋ถ„์ด ์žˆ์–ด์š”.

์ด ๋ถ€๋ถ„์€ Docker ๋‚ด๋ถ€ Network๋ง๊ณผ ์—ฐ๊ฒฐ์„ ํ•ด ์ฃผ๊ธฐ ์œ„ํ•ด ํ•ด๋‹น IP๋ฅผ ์ฐพ๊ณ ์ž Container์— ์ ‘์†์„ ํ•ด ์ฃผ์—ˆ์–ด์š”.


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


์ฐธ๊ณ ๋กœ Bash Shell๋กœ ์ ‘์†ํ•˜๊ธฐ ์œ„ํ•ด ์œ„์™€ ๊ฐ™์ด ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ๋‹ˆ Bash Shell์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค๊ณ  ํ•ด์š”.
๊ทธ๋ž˜์„œ ์œ„์™€ ๊ฐ™์ด Shell์„ ์‚ฌ์šฉํ•˜๋„๋ก ๋ช…๋ น์–ด๋ฅผ ๊ณ ์ณ ์ฃผ์–ด ์ ‘์†ํ•ด ์ฃผ์—ˆ์–ด์š”.


ifconfig


Container ๋‚ด๋ถ€ IP๊ฐ€ ์œ„์™€ ๊ฐ™์ด ์„ค์ • ๋˜ ์žˆ๋Š” ๊ฑธ ํ™•์ธํ•˜์˜€์–ด์š”.

 

docker_registry_config.yml


์ฃผ๋‹ˆํ•˜๋ž‘์€ Docker Host PC์—์„œ ์œ„์™€ ๊ฐ™์ด yml File์„ ์ž…๋ ฅํ•ด ์ฃผ์—ˆ์–ด์š”.


Docker Image ๋‚ด๋ ค ๋ฐ›๊ธฐ ๋ฐ ์‹คํ–‰

 

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



docker container ls


Container๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๊ธฐ๋™ ์ค‘์ธ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.


CATALINA_OPTS: -Djava.security.egd=file:/dev/./urandom -Dcontext.path=
Using CATALINA_BASE:   /var/lib/tomcat7
Using CATALINA_HOME:   /usr/share/tomcat7
Using CATALINA_TMPDIR: /var/lib/tomcat7/temp
Using JRE_HOME:        /usr/lib/jvm/java-7-openjdk-amd64
Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Nov 16, 2022 1:56:23 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Nov 16, 2022 1:56:23 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2288 ms
Nov 16, 2022 1:56:23 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 16, 2022 1:56:23 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.52 (Ubuntu)
2022-11-16 13:57:22,570 [localhost-startStop-1] INFO  hibernate4.HibernatePluginSupport  - Set db generation strategy to 'update' for datasource DEFAULT

Configuring Spring Security Core ...
... finished configuring Spring Security Core

2022-11-16 13:57:27,425 [localhost-startStop-1] INFO  cache.CacheBeanPostProcessor  - postProcessBeanDefinitionRegistry start
2022-11-16 13:57:27,471 [localhost-startStop-1] INFO  cache.CacheBeanPostProcessor  - postProcessBeanFactory
2022-11-16 13:57:31,840 [localhost-startStop-1] WARN  config.ConfigurationFactory  - No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/var/lib/tomcat7/webapps/ROOT/WEB-INF/lib/ehcache-2.9.0.jar!/ehcache-failsafe.xml
2022-11-16 13:57:36,014 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: access_control
2022-11-16 13:57:36,022 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: event
2022-11-16 13:57:36,027 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: role
2022-11-16 13:57:36,034 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: role_access
2022-11-16 13:57:36,039 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: user
2022-11-16 13:57:36,045 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: user_role
2022-11-16 13:57:36,049 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: access_control
2022-11-16 13:57:36,053 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: event
2022-11-16 13:57:36,057 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: role
2022-11-16 13:57:36,062 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: role_access
2022-11-16 13:57:36,067 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: user
2022-11-16 13:57:36,072 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: user_role
2022-11-16 13:57:36,076 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: access_control
2022-11-16 13:57:36,081 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: event
2022-11-16 13:57:36,084 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: role
2022-11-16 13:57:36,089 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: role_access
2022-11-16 13:57:36,094 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: user
2022-11-16 13:57:36,098 [localhost-startStop-1] INFO  sql.DatabaseMetaData  - HHH000262: Table not found: user_role
2022-11-16 13:57:37,205 [localhost-startStop-1] INFO  ehcache.GrailsEhCacheManagerFactoryBean  - Initializing EHCache CacheManager
2022-11-16 13:57:48,440 [localhost-startStop-1] WARN  web.TokenService  - Authorization disabled
2022-11-16 13:57:58,405 [localhost-startStop-1] INFO  filter.AnnotationSizeOfFilter  - Using regular expression provided through VM argument net.sf.ehcache.pool.sizeof.ignore.pattern for IgnoreSizeOf annotation : ^.*cache\..*IgnoreSizeOf$
2022-11-16 13:57:58,429 [localhost-startStop-1] INFO  sizeof.AgentLoader  - Located valid 'tools.jar' at '/usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar'
2022-11-16 13:57:58,479 [localhost-startStop-1] INFO  sizeof.JvmInformation  - Detected JVM data model settings of: 64-Bit OpenJDK JVM with Compressed OOPs
2022-11-16 13:57:58,839 [localhost-startStop-1] INFO  sizeof.AgentLoader  - Extracted agent jar to temporary file /var/lib/tomcat7/temp/ehcache-sizeof-agent4146765445260277451.jar
2022-11-16 13:57:58,839 [localhost-startStop-1] INFO  sizeof.AgentLoader  - Trying to load agent @ /var/lib/tomcat7/temp/ehcache-sizeof-agent4146765445260277451.jar
2022-11-16 13:57:58,867 [localhost-startStop-1] INFO  impl.DefaultSizeOfEngine  - using Agent sizeof engine
2022-11-16 13:57:59,046 [localhost-startStop-1] INFO  impl.DefaultSizeOfEngine  - using Agent sizeof engine
2022-11-16 13:57:59,227 [localhost-startStop-1] INFO  context.GrailsConfigUtils  - [GrailsContextLoader] Grails application loaded.
2022-11-16 13:57:59,498 [localhost-startStop-1] INFO  conf.BootStrap  - Starting registry-web ver. 0.1.3-SNAPSHOT-bededf47611365f0a6d2bb87942e3b86c1e92d9f
2022-11-16 13:57:59,702 [localhost-startStop-1] INFO  web.ConfigService  - [environmentProperties, localProperties]
2022-11-16 13:57:59,742 [localhost-startStop-1] INFO  web.ConfigService  - resolved config:
2022-11-16 13:57:59,757 [localhost-startStop-1] INFO  web.ConfigService  - registry.url: http://172.17.0.2:5000/v2
2022-11-16 13:57:59,758 [localhost-startStop-1] INFO  web.ConfigService  - registry.auth: 
2022-11-16 13:57:59,758 [localhost-startStop-1] INFO  web.ConfigService  - registry.auth.key: /config/auth.key
2022-11-16 13:57:59,758 [localhost-startStop-1] INFO  web.ConfigService  - registry.readonly: false
2022-11-16 13:57:59,759 [localhost-startStop-1] INFO  web.ConfigService  - registry.trust_any_ssl: false
2022-11-16 13:57:59,759 [localhost-startStop-1] INFO  web.ConfigService  - registry.basic_auth: 
2022-11-16 13:57:59,759 [localhost-startStop-1] INFO  web.ConfigService  - registry.enabled: false
2022-11-16 13:57:59,759 [localhost-startStop-1] INFO  web.ConfigService  - registry.auth.enabled: false
2022-11-16 13:57:59,759 [localhost-startStop-1] INFO  web.ConfigService  - registry.context_path: 
2022-11-16 13:57:59,760 [localhost-startStop-1] INFO  web.ConfigService  - registry.auth.issuer: test-issuer
2022-11-16 13:57:59,760 [localhost-startStop-1] INFO  web.ConfigService  - registry.name: 172.17.0.2:5000
2022-11-16 13:57:59,769 [localhost-startStop-1] INFO  conf.BootStrap  - auth enabled: false
Nov 16, 2022 1:58:02 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Nov 16, 2022 1:58:02 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 98505 ms

docker logs {Container ID}

ํ•ด๋‹น Container๊ฐ€ ์ž˜ ๊ธฐ๋™ ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด Log๋ฅผ ๋ณด๋‹ˆ ์ž˜ ์ž‘๋™ํ•œ ๊ฒƒ์œผ๋กœ ํ™•์ธ์„ ํ–ˆ์–ด์š”.




UI๊ฐ€ ์—„์ฒญ ์ด์˜์ง€๋Š” ์•Š์ง€๋งŒ, ์ž˜ ์ ‘์†๋œ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.

 

 

 

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

 

Docker Local Registry ๊ตฌ์ถ•

๊ตฌ์ถ•ํ™˜๊ฒฝ Host VMware® Workstation 14 Player 14.0.0 build-6661328 OS Ubuntu 16.04.6 LTS Application - Docker : 19.03.5, build 633a0ea838 - docker-compose : 1.11.2, build dfed245 - git : 2.7.4 Docker Image๋ฅผ ํ™œ์šฉํ•œ Local Registry ๊ตฌ์ถ• Docker Regis

hihellloitland.tistory.com

 

 

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•