๐Ÿณ์šฐ๋‹นํƒ•ํƒ• Docker ์‹œ์ž‘ํ•ด๋ณด๊ธฐ

๊น€์„ฑ์ธยท2023๋…„ 9์›” 15์ผ
0

[DevOps] ๐ŸณDocker & Kubernetes

๋ชฉ๋ก ๋ณด๊ธฐ
1/62

JPA ๋ฅผ ๊ณต๋ถ€ํ•˜๊ธฐ ์œ„ํ•ด API ์„œ๋ฒ„ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค๋ฉด์„œ, ๋„์ปค ๊ณต๋ถ€๋„ ๋ณ‘ํ–‰์„ ํ•˜๊ธฐ๋กœํ•˜์˜€๋‹ค.

1. ๋„์ปคํŒŒ์ผ ์ƒ์„ฑ

๋„์ปค ๋นŒ๋“œ ์œ„์น˜๋ฅผ ํ„ฐ๋ฏธ๋„์˜ ํ˜„์žฌ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ง€์ •ํ• ๊ฑฐ๋ผ์„œ DockerFile์„ ํ”„๋กœ์ ํŠธ ๋ฐ”๋กœ ์•„๋ž˜ ์œ„์น˜์‹œ์ผฐ๋‹ค.
build -t ๋„์ปคํ—ˆ๋ธŒ์ด๋ฆ„/๋ ˆํฌ์ง€ํ† ๋ฆฌ ๋นŒ๋“œํ• ๋””๋ ‰ํ„ฐ๋ฆฌ

๊ตฌ๊ธ€๋งํ•˜๋ฉด์„œ ๊ณต๋ถ€ํ•˜๋‹ค๊ฐ€ ์‹œ์ž‘ํ•˜์ž๋งˆ์ž ๋นŒ๋“œํ•  ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ํ˜„์žฌ ๋””๋ ‰ํ„ฐ๋ฆฌ๋กœ ์ง€์ •ํ•˜๋Š” "." ์„ ๋ณด์ง€๋„ ์•Š๊ณ  ๋ƒ…๋‹ค ๋ช…๋ น์–ด ์ป๋‹ค๊ฐ€ ๋ฐ”๋กœ ์˜ค๋ฅ˜,,, ๋‹ค์‹œ ์ฐพ์•„๋ณด๊ณ  ์‹คํ–‰ํ•˜๋‹ˆ ๋˜๋”๋ผ.


2. ๋„์ปค ํŒŒ์ผ ์œ„์น˜

๋„์ปค ๋นŒ๋“œ๋ฅผ ํ•˜๊ธฐ์œ„ํ•ด์„œ ๋นŒ๋“œ๋ฅผ ํ•˜๋Š” ๊ฒฝ๋กœ๋ฅผ ์„ค์ •ํ•ด์•ผํ•˜๋Š”๋ฐ "." (ํ˜„์žฌ ๋””๋ ‰ํ„ฐ๋ฆฌ)๋กœ ๋นŒ๋“œ๋ฅผ ํ•˜๋Š” ๋ช…๋ น์–ด๋ฅผ ํ•ด๋†“๊ณ  ๋„์ปคํŒŒ์ผ์„ ๋‹ค๋ฅธ์œ„์น˜์— ๋†”๋’€์Œ..
build -t ๋„์ปคํ—ˆ๋ธŒ์ด๋ฆ„/๋ ˆํฌ์ง€ํ† ๋ฆฌ ๋นŒ๋“œํ• ๋””๋ ‰ํ„ฐ๋ฆฌ ์—์„œ "๋นŒ๋“œํ•  ๋””๋ ‰ํ„ฐ๋ฆฌ" ๋ถ€๋ถ„์— ๋„์ปคํŒŒ์ผ์„ ์œ„์น˜ ์‹œํ‚ค์ž..


3. ๋„์ปค ํŒŒ์ผ ๋ฌธ๋ฒ•

๋„์ปค ํŒŒ์ผ ๋‚ด๋ถ€์— ๋ช…๋ น์–ด๋Š” ๋„์›Œ์“ฐ๊ธฐ๋ฅผ ๊ต‰์žฅํžˆ ๋งŽ์ด ๊ณ ๋ คํ•˜๋Š”๋“ฏ ํ•˜๋‹ค..
EntryPoint ["java" ~ ์ด๋Ÿฐ์‹์œผ๋กœ ์ป์–ด์•ผ ๋˜๋Š”๋ฐ ๋„์›Œ์“ฐ๊ธฐ ์•ˆํ•ด์„œ ๋˜ ์—๋Ÿฌ๋‚จ..

FROM amazoncorreto:11
ARG JAR_FILE=*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","Duser.timezone=Asia/Seoul","/app.jar"]

์œ„์ฒ˜๋Ÿผ ๊ณ ์นจ


4. amazoncorreto ์ด์Šˆ

access denied

ERROR: failed to solve: amazoncorreto:11: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

์ž๋ฐ” ์ด๋ฏธ์ง€ ๋ณ€๊ฒฝ

FROM amazoncorreto:11
ARG JAR_FILE=*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","Duser.timezone=Asia/Seoul","/app.jar"]
  • ํ˜„์žฌ ์ธํ…”๋ฆฌ์ œ์ด๋ฅผ ์ด์šฉํ•˜์—ฌ ๋กœ์ปฌํ™˜๊ฒฝ ํ„ฐ๋ฏธ๋„์„ ์ด์šฉํ•ด ๋นŒ๋“œ๋ฅผ ํ•˜๊ณ  ์žˆ์–ด์„œ, ํ˜น์‹œ๋‚˜ํ•˜๊ณ  openjdk๋ผ๊ณ  ๋ฐ”๊ฟ”๋ดค๋Š”๋ฐ ๋นŒ๋“œ์— ์„ฑ๊ณตํ•˜์˜€๋‹ค
  • ๋นŒ๋“œ์‹œ ๋„์ปค ์ด๋ฏธ์ง€๋ฅผ ๋นŒ๋“œํ•˜๋Š” ํ™˜๊ฒฝ๋„ ๊ณ ๋ คํ•ด์•ผํ•˜๋Š” ๊ฑด๊ฐ€..

์ด๋ฏธ์ง€ ํ™•์ธ ๋ฐ ๋ ˆํฌ์ง€ํ† ๋ฆฌ ํ‘ธ์‹œ

> docker images
> docker push ๋„์ปคํ—ˆ๋ธŒ์ด๋ฆ„/๋ ˆํฌ์ง€ํ† ๋ฆฌ์ด๋ฆ„
  • ๋กœ๊ทธ
  • ๋„์ปค ํ—ˆ๋ธŒ

๋ญ”๊ฐ€ ๋˜๊ธฐ ์‹œ์ž‘ํ–ˆ๋‹ค..!


๋„์ปค ์‹คํ–‰

๋นŒ๋“œ๋Š” ์ž˜๋ฌ๋Š”๋ฐ ์‹คํ–‰์ด ์•ˆ๋˜์–ด์„œ,, ๋ฌธ์ œ๋ฅผ ํ™•์ธํ–ˆ๋”๋‹ˆ
๋„์ปคํŒŒ์ผ ๋นŒ๋“œ ํ›„ JARํŒŒ์ผ ์œ„์น˜๊ฐ€ ์ƒ๋Œ€ ๊ฒฝ๋กœ๋กœ ์ธ์‹๋˜๊ธฐ ๋•Œ๋ฌธ์ด์—ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค.

FROM amazoncorreto:11
ARG JAR_FILE=*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","Duser.timezone=Asia/Seoul","/app.jar"]


๋„์ปค ์‹คํ–‰ ์™„๋ฃŒ

์ด๋ฏธ์ง€๋ฅผ ์ด์šฉํ•˜์—ฌ ์ปจํ…Œ์ด๋„ˆ ์‹คํ–‰์ด ์™„๋ฃŒ๋˜๋Š” ๋ชจ์Šต

FROM openjdk:11
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","-Duser.timezone=Asia/Seoul","/app.jar"]


์•„์ง๊นŒ์ง€ ๋„์ปค์˜ ์ด๋ฏธ์ง€์™€ ์ปจํ…Œ์ด๋„ˆ๋ผ๋Š” ๊ฐœ๋…์„ ์ดํ•ดํ•˜์ง€ ๋ชปํ•ด์„œ ์ „๋ฐ˜์ ์œผ๋กœ ๋ถ€์กฑํ•œ ๋ถ€๋ถ„์ด ๋„ˆ๋ฌด ๋งŽ์€ ๊ฒƒ ๊ฐ™๋‹ค... ๊ฐœ๋…๊ณต๋ถ€๋ฅผ ์ข€ ๋”ํ•˜๊ณ  ๊ฐ ๊ฐ’์ด ์–ด๋–ค ์˜๋ฏธ๋ฅผ ๊ฐ€์ง€๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ๊ตฌ๊ธ€๋งํ•˜๋ฉด์„œ ํ”„๋กœ์ ํŠธ์— ์ ‘๊ทผ ํ•ด์•ผํ• ๊ฒƒ๊ฐ™๋‹ค,..

์ฐธ๊ณ  ๋ธ”๋กœ๊ทธ

์„ค๋ช… ์ž˜ํ•ด์คŒ : https://note.hatemogi.com/docker-spring.html
๊ธฐ๋ณธ ํ๋ฆ„ : https://velog.io/@appti/%EB%8F%84%EC%BB%A4%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EC%8A%A4%ED%94%84%EB%A7%81-%EB%B6%80%ED%8A%B8

0๊ฐœ์˜ ๋Œ“๊ธ€