[Docker๐Ÿณ] ์ถ”๊ฐ€ docker ๋ช…๋ น์–ด

Jeong SeongYunยท2022๋…„ 10์›” 8์ผ
0

Docker

๋ชฉ๋ก ๋ณด๊ธฐ
7/10
post-thumbnail

์šฐ๋ฆฌ๊ฐ€ ์ง€์ง€๋‚œ ํฌ์ŠคํŠธ์— ๋‹ค๋ค˜๋˜ docker ๋ช…๋ น์–ด๋“ค๋งŒ ์•Œ์•„๋„ ๋ญ ์–ด๋Š ์ •๋„ ๋งŒ๋“ค ์ˆ˜๋Š” ์žˆ๊ฒ ์ง€๋งŒ ์‹ค์งˆ์ ์œผ๋กœ ์„œ๋น„์Šค๋ฅผ ํ•˜๊ธฐ ์œ„ํ•ด์„  ๋” ๋งŽ์€ ๋ช…๋ น์–ด๋“ค์„ ์•Œ์•„๋‘ฌ์•ผํ•ฉ๋‹ˆ๋‹ค.๐Ÿ˜ฃ

๊ทธ ๋ช…๋ น์–ด๋“ค์— ๋Œ€ํ•ด ๊ฐ„๋‹จํ•˜๊ฒŒ ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.


์ปจํ…Œ์ด๋„ˆ ์ •๋ณด ํŒŒ์•…ํ•˜๊ธฐ

docker history

์ด๋ฏธ์ง€๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” Layer์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์•Œ๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉ

docker history

docker cp

์ปจํ…Œ์ด๋„ˆ์˜ ํŠน์ • ํŒŒ์ผ์„ Host PC๋กœ ๊ฐ€์ ธ์˜ค๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉ
๋ฐ˜๋Œ€๋กœ Host PC์˜ ํŒŒ์ผ์„ ์‹คํ–‰๋˜๊ณ  ์žˆ๋Š” ์ปจํ…Œ์ด๋„ˆ ์•ˆ์— ๋„ฃ์„ ์ˆ˜๋„ ์žˆ๋‹ค!

docker cp {์ปจํ…Œ์ด๋„ˆ ์ด๋ฆ„:ํŒŒ์ผ๊ฒฝ๋กœ} {Host PC์— ๋„ฃ์„ ๊ฒฝ๋กœ}
docker cp {Host PC์— ๋„ฃ์„ ๊ฒฝ๋กœ} {์ปจํ…Œ์ด๋„ˆ ์ด๋ฆ„:ํŒŒ์ผ๊ฒฝ๋กœ}

โ— docker commit

์ปจํ…Œ์ด๋„ˆ์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ด๋ฏธ์ง€ ํŒŒ์ผ๋กœ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ
๊ธฐ์กด ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค๊ฐ€ ์ƒˆ๋กœ์šด ์ด๋ฏธ์ง€๋ฅผ ์„ค์น˜ํ•˜๊ฑฐ๋‚˜ ๋ณ€๊ฒฝํ•œ ์ƒํƒœ์˜ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ด๋ฏธ์ง€๋กœ ์ €์žฅํ•˜๋Š” ๊ฒƒ!!!
git commit ๊ณผ ์™„์ „ ์œ ์‚ฌํ•˜๋‹ค!

docker commit -m "๋ญ ๋ฐ”๊ฟจ์–ด์šฉ!" {์ €์žฅ๋  ์ปจํ…Œ์ด๋„ˆ ์ด๋ฆ„} {์ƒˆ๋กœ ์ƒ์„ฑ๋  ์ปจํ…Œ์ด๋„ˆ ์ด๋ฆ„}

docker diff

์ด์ „ ๋ฒ„์ „์˜ ์ปจํ…Œ์ด๋„ˆ์™€ ๋น„๊ตํ•ด์„œ ๋ณ€๊ฒฝ๋œ ํŒŒ์ผ ๋ชฉ๋ก์„ ์ถœ๋ ฅ
๋ณ€๊ฒฝ ์ˆœ์„œ์™€ ์ƒ๊ด€ ์—†์ด ์ถœ๋ ฅ๋œ๋‹ค.

docker diff {์ปจํ…Œ์ด๋„ˆ ์ด๋ฆ„}
A : ์ถ”๊ฐ€๋จ
D : ์‚ญ์ œ๋จ
C : ์ˆ˜์ •๋จ



โ— ์ปจํ…Œ์ด๋„ˆ ๋ผ๋ฆฌ ์—ฐ๊ฒฐํ•˜๊ธฐ

ํŠน์ • ์ปจํ…Œ์ด๋„ˆ์™€ ๋‹ค๋ฅธ ์ปจํ…Œ์ด๋„ˆ๋ฅผ "๋‚ด๋ถ€์ ์œผ๋กœ ์—ฐ๊ฒฐ"ํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉ
DB์— ์™ธ๋ถ€ ํฌํŠธ๋ฅผ ์—ด์–ด๋‘๋ฉด ์™ธ๋ถ€ ๊ณต๊ฒฉ์— ๋งค์šฐ ์ทจ์•ฝํ•ด์ง€๋ฏ€๋กœ ์•„์˜ˆ DB Container๋ฅผ ๋”ฐ๋กœ ๋งŒ๋“ค์–ด ๋‚ด๋ถ€ ์ปจํ…Œ์ด๋„ˆ์—์„œ๋งŒ ์ •๋ณด๊ฐ€ ๊ตํ™˜๋˜๊ฒŒ ๋งŒ๋“ ๋‹ค!!
docker run ~~~~~ --link {์ปจํ…Œ์ด๋„ˆ ์ด๋ฆ„:๋ณ„๋ช…}


profile
๋ฌผ์–ด๋ณด๋ฉด ๋Œ€๋‹ตํ•ด์ค„ ์ˆ˜ ์žˆ๋Š” ๋ฐ์ดํ„ฐ์Ÿ์ด

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