2022. 11. 16. 17:07ใSystem ์์ ์ค/Docker
๐ ๋ชฉ์ฐจ
โ [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 ์ ๋ณด
โ Hardware ์ ๋ณด
Virtual Machine
โ VM Application
โ VM
- OS ์ ๋ณด
- Hardware ์ ๋ณด
Application
๐ฝ Docker Registry
๐ฆ ์ค์น
์ต์ด Docker Image๋ฅผ Pull ํ์ฌ ์ค ๊ฑฐ์์.
์ต์ Version์ Docker 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 ์ฌ ๊ธฐ๋์ ์๋์ผ๋ก ํด๋น ์ ๋ณด๋ฅผ ๊ฐ์ ธ๊ฐ๊ฒ ๋๋ค.
registry Docker๊ฐ ๊ธฐ๋ ์ค์ธ๊ฑธ ํ์ธํ ์ ์์ด์.
๐ฝ Docker Registry Dashboard
๐ฆ Web Service ๊ตฌ์ถ
์ด๋ฒ์๋ ์ฐ๋ฆฌ ํฌ๋ฃจ๋ค์ด ๋ณด๋ค ํธ๋ฆฌํ๊ฒ Container๋ค์ ๊ด๋ฆฌํ ์ ์๋๋ก Web Service์์ ๋ด์ฉ๋ค์ ํ์ธํ ์ ์๋๋ก ๊ตฌ์ถํด ๋ณผ๊ฒ์.
์ต์ด Docker-Registry-Web์ ์ค์นํ๊ธฐ ์ํด yml File์ ์์ฑํด ์ฃผ์ด์ผ ํด์.
yml์ ์ค์ ํ๊ธฐ ์ํด Docker Registry์ IP๋ฅผ ์ค์ ํ๋ ๋ถ๋ถ์ด ์์ด์.
์ด ๋ถ๋ถ์ Docker ๋ด๋ถ Network๋ง๊ณผ ์ฐ๊ฒฐ์ ํด ์ฃผ๊ธฐ ์ํด ํด๋น IP๋ฅผ ์ฐพ๊ณ ์ Container์ ์ ์์ ํด ์ฃผ์์ด์.
์ฐธ๊ณ ๋ก Bash Shell๋ก ์ ์ํ๊ธฐ ์ํด ์์ ๊ฐ์ด ๋ช
๋ น์ด๋ฅผ ์
๋ ฅํด ์ฃผ๋ Bash Shell์ ์ฌ์ฉํ ์ ์๋ค๊ณ ํด์.
๊ทธ๋์ ์์ ๊ฐ์ด Shell์ ์ฌ์ฉํ๋๋ก ๋ช
๋ น์ด๋ฅผ ๊ณ ์ณ ์ฃผ์ด ์ ์ํด ์ฃผ์์ด์.
Container ๋ด๋ถ IP๊ฐ ์์ ๊ฐ์ด ์ค์ ๋ ์๋ ๊ฑธ ํ์ธํ์์ด์.
์ฃผ๋ํ๋์ Docker Host PC์์ ์์ ๊ฐ์ด yml File์ ์
๋ ฅํด ์ฃผ์์ด์.
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
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๊ฐ ์์ฒญ ์ด์์ง๋ ์์ง๋ง, ์ ์ ์๋๊ฑธ ํ์ธํ ์ ์์ด์.
๐ง ์ฐธ๊ณ ์๋ฃ
'System ์์ ์ค > Docker' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[DevOps - CentOS 7.9] Docker Remote Registry ์ฌ์ฉ๋ฒ (0) | 2022.11.16 |
---|---|
[DevOps - CentOS 7.9] Docker Local Registry ์ฌ์ฉ๋ฒ (0) | 2022.11.16 |
[DevOps] NGINX๋? (0) | 2022.10.07 |
[Docker] Jenkins Slave ์ค์น ๋ฐ Master์ ์ฐ๊ฒฐํ๊ธฐ (0) | 2022.09.16 |
[Docker] โ docker์ AWS๋ฅผ ์ด์ฉํ Web Application ๋ฐฐํฌ (0) | 2021.08.01 |