๐Ÿ“’ [ TIL ] 2022.07.08_57์ผ์ฐจ # Docker (2)

๋ฌธ๋ช…์ฃผยท2022๋…„ 7์›” 9์ผ
0
post-thumbnail

[ 2022-07-08 (๊ธˆ) ์˜ค๋Š˜์˜ TIL ]

[ Today Learn ]

  • Docker๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋ณต์žกํ•œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ฐฐํฌํ•˜๋Š” ๋ฐฉ๋ฒ•
  • docker-compose, docker image ์ตœ์ ํ™” ๋“ฑ Docker๋ฅผ ๋” ์ž˜ ํ™œ์šฉํ•˜๊ธฐ ์œ„ํ•œ ๊ฟ€ํŒ

โœ๏ธ ๋‚ด๊ฐ€ ๋ฐฐ์šด๊ฒƒ, ์–ป์€๊ฒƒ

* ๋‚ด๊ฐ€ ์›ํ•˜๋Š” volume์„ docker container์— ์—ฐ๊ฒฐํ•˜๊ธฐ

โ“ Docker bind mount ๋ž€ ?
๋‚ด๊ฐ€ ์›ํ•˜๋Š” volume์„ docker container ๋‚ด์˜ volume์— ์—ฐ๊ฒฐํ•˜๋Š” ๊ธฐ๋Šฅ์œผ๋กœ bind mount์˜ ๋ฌธ๋ฒ•์€ named volume๊ณผ ๊ฑฐ์˜ ๋น„์Šทํ•˜๋‹ค.

๐Ÿงฉ ์ ์šฉ ์˜ˆ์‹œ

docker run -v {host_path}:{container_path} <docker_image>

* Docker์—์„œ ์—ฌ๋Ÿฌ๊ฐœ์˜ container๋ฅผ ์—ฐ๊ฒฐํ•˜๊ธฐ

โ“ Docker network ๋ž€ ?
Docker container๋Š” ๋ถ„๋ฆฌ๋œ filesystem๊ณผ ๋„คํŠธ์›Œํฌ๋ฅผ ๊ฐ€์ง€๋ฉฐ ๋”ฐ๋กœ ์„ค์ •์ด ์—†์œผ๋ฉด filesystem๊ณผ network ํ†ต์‹ ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค.

  1. docker network ์ƒ์„ฑํ•˜๊ธฐ
docker network create test
  1. docker network ์—ฐ๊ฒฐํ•ด์„œ container ์‹คํ–‰ํ•˜๊ธฐ
docker run -d -p 24017:24017 --network test --network-alias mongo mongo
  1. container์—์„œ ๋‹ค๋ฅธ container ํ˜ธ์ถœํ•˜๊ธฐ
docker run -it --network test nicolaka/netshoot
> dig mongo

* Docker-compose ์•Œ์•„๋ณด๊ธฐ

โ“ Docker-compose ๋ž€ ?
์—ฌ๋Ÿฌ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ํŽธ๋ฆฌํ•˜๊ฒŒ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋งŒ๋“ค์–ด๋‘” ๋„๊ตฌ๋กœ์„œ YAML ํŒŒ์ผ์„ ํ†ตํ•ด container๋ฅผ ์‹คํ–‰ํ•˜๋Š”๋ฐ ํ•„์š”ํ•œ ์˜ต์…˜์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋‹ค. YAML์ด๋ž€ YAML Ain't Markup Language ์œผ๋กœ, ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š” ํŒŒ์ผ ํฌ๋งท์ด๋ฉฐ, ๋น„์Šทํ•œ ํ˜•์‹์œผ๋กœ XML๊ณผ JSON์ด ์กด์žฌํ•˜์ง€๋งŒ, ์‚ฌ๋žŒ์ด ์ฝ๊ธฐ๊ฐ€ ๋” ํŽธํ•˜๋‹ค๋Š” ์žฅ์ ์ด ์žˆ๋‹ค.

profile
ํ•˜๋ฃจ ํ•œ๊ฑธ์Œ์”ฉ ๊พธ์ค€ํžˆ ๋‚˜์•„๊ฐ€๋Š” ๊ฐœ๋ฐœ์ž๐Ÿ™†โ€โ™€๏ธ https://github.com/Moonmooj

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

๊ด€๋ จ ์ฑ„์šฉ ์ •๋ณด