BACKEND/Docker & Kubernetes

Docker Network, ์ œ๋Œ€๋กœ ์ดํ•ดํ•˜๊ธฐ (2)

gngsn 2022. 2. 15. 23:29

๐Ÿ“Œ  Docker Series

Docker Engine, ์ œ๋Œ€๋กœ ์ดํ•ดํ•˜๊ธฐ (1) -  docker engine deep dive

Docker Engine, ์ œ๋Œ€๋กœ ์ดํ•ดํ•˜๊ธฐ (2) - namespace, cgroup

Docker Network, ์ œ๋Œ€๋กœ ์ดํ•ดํ•˜๊ธฐ (1) - libnetwork

> Docker Network, ์ œ๋Œ€๋กœ ์ดํ•ดํ•˜๊ธฐ (2) - bridge, host, none drivers

Docker, ์ œ๋Œ€๋กœ ์‚ฌ์šฉํ•˜๊ธฐ - Commands

 

 

์•ˆ๋…•ํ•˜์„ธ์š”.

์˜ค๋Š˜์€ Docker Network๋ฅผ Deep Diveํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค.

์ง€๋‚œ Docker ์‹œ๋ฆฌ์ฆˆ๋กœ Docker Engine์— ๋Œ€ํ•ด ๋‹ค๋ฃจ๊ณ  3๋ถ€๋กœ ์ง„ํ–‰ํ•˜๋ ค ํ–ˆ๋˜ Network์— ํ•ด๋‹น๋ฉ๋‹ˆ๋‹ค.

๋‚ด์šฉ๋„ ๋งŽ๊ณ  ๊ฐ€๋ฒผ์šด ์ฃผ์ œ๊ฐ€ ์•„๋‹ˆ๋ผ ์‹œ๋ฆฌ์ฆˆ๋ฅผ ๋”ฐ๋กœ ๊ตฌ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค ใ€ฐ๏ธ

 

 

ํ•ด๋‹น ํฌ์ŠคํŒ…์€ ๋„คํŠธ์›Œํฌ์— ๋Œ€ํ•œ ๊ธฐ๋ณธ์ ์ธ ๋‚ด์šฉ์„ ์ถฉ๋ถ„ํžˆ ์ตํ˜”๋‹ค๋Š” ๊ฐ€์ •ํ•˜์— ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ, ๋ชจ๋“  ๊ทธ๋ฆผ์€ ์ง์ ‘ ๊ทธ๋ฆฐ ๊ฒƒ์œผ๋กœ, ์‚ฌ์šฉ์‹œ ์ถœ์ฒ˜ ํ‘œ์‹œ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค ๐Ÿ™๐Ÿป.

 

---------------    INDEX     --------------

[ 1๋ถ€ ]

CNM

Libnetwork

Driver

 

[ 2๋ถ€ ]

Drivers

- Bridge

- Host

- None

 

[ 3๋ถ€ ]

- Overlay

- Macvlan

----------------------------------------------

 

Drivers

Docker์˜ drivers์—๋Š” Bridge, Overlay, Host, Macvlan, Ipvlan, None์œผ๋กœ ์ด 6๊ฐœ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. 

 

๊ฐ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ž ๊น ํ›‘์–ด๋ณด์ž๋ฉด ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

ํ•ด๋‹น ๋‚ด์šฉ์€ Docker์˜ ๊ณต์‹๋ฌธ์„œ ๋‚ด์šฉ์„ ๋ฒˆ์—ญํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

โœ”๏ธ  Driver ์š”์•ฝ

User-defined bridge networks : ๊ฐ™์€ ํ˜ธ์ŠคํŠธ ์ƒ์—์„œ ์—ฌ๋Ÿฌ ์ปจํ…Œ์ด๋„ˆ์˜ ํ†ต์‹ ์ด ํ•„์š”ํ•  ๋•Œ

None networks : ์ตœ์†Œํ•œ์˜ ๋„คํŠธ์›Œํฌ ํ™˜๊ฒฝ๋งŒ์„ ์ƒ์„ฑํ•˜๊ณ  ์‹ถ์„ ๋•Œ

Host networks : ์ปจํ…Œ์ด๋„ˆ๋กœ ๋ถ„๋ฆฌ๋˜๊ธธ ์›ํ•˜์ง€๋งŒ, ๋„คํŠธ์›Œํฌ ์Šคํƒ์€ ๋ถ„๋ฆฌ๋˜์ง€ ์•Š๊ธธ ์›ํ•  ๋•Œ (ํ˜ธ์ŠคํŠธ ๋„คํŠธ์›Œํฌ๋ฅผ ๊ฐ™์ด ์“ฐ๊ธธ ์›ํ•  ๋•Œ)

Overlay networks : ๋‹ค๋ฅธ ํ˜ธ์ŠคํŠธ ์ƒ์—์„œ ์‹คํ–‰๋˜๋Š” ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ํ†ต์‹ ํ•ด์•ผ ํ•  ๋•Œ๋‚˜, ์Šค์›œ ์„œ๋น„์Šค๋กœ ์—ฌ๋Ÿฌ ์•ฑ์ด ์‹คํ–‰๋˜์–ด์•ผ ํ•  ๋•Œ

Macvlan networks : VM ํ™˜๊ฒฝ์—์„œ๋ถ€ํ„ฐ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ํ•ด์•ผํ•˜๊ฑฐ๋‚˜, ๋„คํŠธ์›Œํฌ ์ƒ์—์„œ ๊ณ ์œ ํ•œ MAC ์ฃผ์†Œ๋ฅผ ๊ฐ€์ง„ ๋ฌผ๋ฆฌ์ ์ธ ํ˜ธ์ŠคํŠธ์ฒ˜๋Ÿผ ๋ณด์—ฌ์•ผ ํ•  ๋•Œ

 

 

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ์„ธ ๊ฐ€์ง€๋งŒ ๋‹ค๋ฃฐ ๊ฑด๋ฐ์š”.

Docker๋ฅผ ์„ค์น˜ํ•˜๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ bridge, host, none ์ด๋ ‡๊ฒŒ ์„ธ ๊ฐœ์˜ ๋„คํŠธ์›Œํฌ๊ฐ€ ์ง€์ •๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

$ docker network ls
NETWORK ID     NAME       DRIVER    SCOPE
e3538e12295b   bridge     bridge    local
18883d2dc038   host       host      local
21c84259960a   none       null      local

 

 

์œ„ ์„ธ ๊ฐœ์˜ ๋„คํŠธ์›Œํฌ๋ฅผ ๊ทธ๋ฆผ์œผ๋กœ ํ‘œํ˜„ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์•„์š”.

์•„๋ž˜ ๋‚ด์šฉ์„ ์ฝ๊ณ  ๋‹ค์‹œ ๋ณด๋ฉด ๋” ๋„์›€์ด ๋  ๋“ฏ ํ•˜๋„ค์š”.

 

 

 

 

Bridge๋ชจ๋“œ๋Š” ๋ธŒ๋ฆฌ์ง€๋ฅผ ํ†ตํ•ด ์—ฐ๊ฒฐ๋œ ์ปจํ…Œ์ด๋„ˆ๋“ค์ด ๋ณด์ด๊ณ ,

Host ๋ชจ๋“œ๋Š” ํ˜ธ์ŠคํŠธ์™€ ๋„คํŠธ์›Œํฌ๋ฅผ ๊ณต์œ ํ•˜๋Š” ์ปจํ…Œ์ด๋„ˆ,

None ๋ชจ๋“œ๋Š” ๋„์ปค ํ˜ธ์ŠคํŠธ์™€ ๊ฒฉ๋ฆฌ๋˜์–ด ๋„คํŠธ์›Œํฌ๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.

 

์ด ์„ธ ๊ฐœ๋ฅผ ์šฐ์„  ํ™•์ธํ•ด๋ณด๊ณ  ๋‹ค๋ฅธ ๊ฒƒ๋“ค์„ ์ˆœ์ฐจ์ ์œผ๋กœ ํ™•์ธํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

 

 

Bridge

๋„์ปค ๋„คํŠธ์›Œํฌ์˜ ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ์œ ํ˜•์ด single-host bridge network์ž…๋‹ˆ๋‹ค.

์–ด๋–ค ์˜๋ฏธ๋ฅผ ๊ฐ–๋Š”์ง€ ๋‹จ์–ด๋ฅผ ์ชผ๊ฐœ์„œ ๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

Signle-host๋Š” ๋‹จ์ผ ๋„์ปค ํ˜ธ์ŠคํŠธ์—๋งŒ ์กด์žฌํ•˜๋ฉฐ ๋™์ผํ•œ ํ˜ธ์ŠคํŠธ์— ์žˆ๋Š” ์ปจํ…Œ์ด๋„ˆ๋งŒ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Œ์„ ์•Œ๋ ค์ค๋‹ˆ๋‹ค.

Bridge๋Š” 802.1d ๋ธŒ๋ฆฌ์ง€(๋ ˆ์ด์–ด 2 ์Šค์œ„์น˜)์˜ ๊ตฌํ˜„์ž„์„ ์•Œ๋ ค์ค๋‹ˆ๋‹ค.

 

์ฆ‰, ๋‹จ์ผ ํ˜ธ์ŠคํŠธ ์ƒ์˜ ๋ธŒ๋ฆฌ์ง€ ์—ญํ• ์„ ํ•˜๋Š” ๋“œ๋ผ์ด๋ฒ„๋ผ๋Š” ๋œป์„ ๊ฐ–๋Š”๋ฐ์š”.

ํ•˜๋‚˜์˜ ํ˜ธ์ŠคํŠธ์—์„œ ์‹คํ–‰๋˜๋Š” ๊ฒฉ๋ฆฌ๋œ ์ปจํ…Œ์ด๋„ˆ๋“ค์˜ ํ†ต์‹ ์„ ์œ„ํ•ด ๋„คํŠธ์›Œํฌ๋ฅผ ์—ฐ๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

์ฐธ๊ณ ๋กœ, ๋‹ค์ค‘ ํ˜ธ์ŠคํŠธ์—์„œ๋Š” overlay ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

Bridge๋Š” ์ง€๋‚œ ํฌ์ŠคํŒ…์˜ docker0๊ฐ€ ๊ธฐ๋ณธ Bridge Network์ด๊ธฐ ๋•Œ๋ฌธ์— ํ•œ ๋ฒˆ ๋‹ค๋ค˜์—ˆ๋Š”๋ฐ์š”.

Bridge์— ๋Œ€ํ•ด ๋‹ค์‹œ ํ•œ ๋ฒˆ ์š”์•ฝํ•˜์ž๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

 

Bridge Network

: Docker ๋ธŒ๋ฆฌ์ง€๋Š” ์ปจํ…Œ์ด๋„ˆ ๊ฐ„ ํ†ต์‹ ์„ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ์†Œํ”„ํŠธ์›จ์–ด ๋ธŒ๋ฆฌ์ง€์ธ ๋™์‹œ์—,

์„œ๋กœ ๋‹ค๋ฅธ ๋ธŒ๋ฆฌ์ง€ ๋„คํŠธ์›Œํฌ์™€์˜ ๊ฒฉ๋ฆฌ๋ฅผ ํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.

 

 

์ด๋ฒˆ์—” docker์—์„œ ๊ธฐ๋ณธ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” docker0๊ฐ€ ์•„๋‹Œ ์‚ฌ์šฉ์ž๊ฐ€ ์ •์˜ํ•˜๋Š” bridge Network์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

 

 

โœ”๏ธ User-defined Bridge

์‚ฌ์šฉ์ž ์ •์˜ ๋ธŒ๋ฆฌ์ง€ ๋„คํŠธ์›Œํฌ๋Š” ๊ฐ™์€ ํ˜ธ์ŠคํŠธ ์ƒ์—์„œ ์—ฌ๋Ÿฌ ์ปจํ…Œ์ด๋„ˆ์˜ ํ†ต์‹ ์ด ํ•„์š”ํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

docker0์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ Bridge ๋„คํŠธ์›Œํฌ์ง€๋งŒ, ๊ทธ ์ด๋ฆ„๊ณผ ๊ตฌ์„ฑ์„ ์‚ฌ์šฉ์ž๊ฐ€ ์ •์˜ํ•˜๋Š” ๊ฒƒ์˜ ์ฐจ์ด๋งŒ ์žˆ์ฃ .

 

์ด ๋ถ€๋ถ„์€ ์˜ˆ์‹œ๋ฅผ ๋ณด๋ฉฐ ์ดํ•ดํ•˜๋Š” ๊ฒƒ์ด ๊ฐ€์žฅ ์‰ฌ์šธ ๊ฒƒ ๊ฐ™์•„์š”.

๋จผ์ €, ์•„๋ž˜์™€ ๊ฐ™์ด localnet์ด๋ผ๋Š” ๋ธŒ๋ฆฌ์ง€ ๋„คํŠธ์›Œํฌ(single-host bridge network)๋ฅผ ํ•˜๋‚˜ ์ƒ์„ฑํ•ด๋ณผ๊ฒŒ์š”.

์ฐธ๊ณ ๋กœ, Linux์—์„œ ๊ธฐ๋ณธ ์ƒ์„ฑ๋˜๋Š” bridge๋Š” Windows์—์„œ๋Š” nat์— ํ•ด๋‹นํ•ฉ๋‹ˆ๋‹ค.

 

//Linux
$ docker network create -d bridge localnet

//Windows
> docker network create -d nat localnet

 

Linux์˜ ๊ฒฝ์šฐ, ์ด๋ ‡๊ฒŒ docker ๋ช…๋ น์„ ํ†ตํ•ด ๋„คํŠธ์›Œํฌ๋ฅผ ์ƒ์„ฑํ•˜๋ฉด ์ƒˆ๋กœ์šด Linux bridge๋„ ์ƒ์„ฑ๋˜๋Š”๋ฐ

brctl ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

Linux brctl ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ˜„์žฌ ์‹œ์Šคํ…œ์— ์žˆ๋Š” Linux ๋ธŒ๋ฆฌ์ง€๋ฅผ ์‚ดํŽด๋ด…์‹œ๋‹ค.

apt-get install bridge-utils ๋˜๋Š” Linux Distro์™€ ๊ฐ™์€ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ˆ˜๋™์œผ๋กœ brctl ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

$ brctl show
bridge name       bridge id             STP enabled    interfaces
docker0           8000.0242aff9eb4f     no
br-20c2e8ae4bbb   8000.02429636237c     no

 

์ฒซ ๋ฒˆ์งธ ์ค„์€ ๊ธฐ๋ณธ "bridge" ๋„คํŠธ์›Œํฌ์— ๊ด€๋ จ๋˜์–ด ์œ„์—์„œ ํ™•์ธํ–ˆ๋˜ "docker0" bridge์ด๊ณ ,

๋‘ ๋ฒˆ์งธ bridge(br-20c2e8ae4bbb)๋Š” ์ƒˆ๋กœ์šด localnet docker bridge network์™€ ๊ด€๋ จ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋‘ ๋ธŒ๋ฆฌ์ง€ ๋ชจ๋‘ interfaces์— ํ• ๋‹น๋œ ๊ฐ’์ด ์—†๋Š”๋ฐ์š”.

์—ฐ๊ฒฐ๋œ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์—†๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

test1 ์ด๋ผ๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด๋ณผ๊ฒŒ์š”.

 

$ docker container run -d --name test1 \
  --network localnet \
  alpine sleep 1d

 

์ด๋ ‡๊ฒŒ localnet์„ ์‚ฌ์šฉํ•˜๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ํ•˜๋‚˜ ์‹คํ–‰์‹œํ‚ค๋ฉด, 

์•„๋ž˜์™€ ๊ฐ™์ด ์—ฐ๊ฒฐ๋ฉ๋‹ˆ๋‹ค.

 

$ brctl show
bridge name       bridge id           STP enabled     interfaces
br-20c2e8ae4bbb   8000.02429636237c   no              vethe792ac0
docker0           8000.0242aff9eb4f   no

 

test1์„ ์‹คํ–‰ํ•  ๋•Œ

์ƒ์„ฑ๋œ ์ปจํ…Œ์ด๋„ˆ ๋‚ด์˜ ๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค eth0์™€,

๊ทธ๋ฆฌ๊ณ  ํ•จ๊ป˜ ์ƒ์„ฑ๋œ vethe792ac0 ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ์กด์žฌํ•˜๊ณ ,

์ด vethe792ac0 ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ localnet(br-20c2e8ae4bbb)์— ์—ฐ๊ฒฐ๋˜์–ด

์™ธ๋ถ€ ๋„คํŠธ์›Œํฌ์™€ ์—ฐ๊ฒฐ์ด ๋ฉ๋‹ˆ๋‹ค.

 

ํ˜„์žฌ ๋งŒ๋“ค์–ด๋‘” ๊ตฌ์กฐ๋ฅผ ๊ทธ๋ฆผ์œผ๋กœ ํ‘œํ˜„ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

 

 

 

ํ•˜๋‚˜์˜ Bridge๋ฅผ ์ƒ์„ฑํ–ˆ๊ณ , ์ด๋Š” ํ˜ธ์ŠคํŠธ์˜ ์ธํ„ฐํŽ˜์ด์Šค์™€๋„ ์—ฐ๊ฒฐ๋˜์–ด์žˆ๊ธฐ ๋•Œ๋ฌธ์— ํ†ต์‹ ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค.

๋งŒ์•ฝ, ๋‹ค๋ฅธ ์ปจํ…Œ์ด๋„ˆ์™€ ์—ฐ๊ฒฐํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด localnet ๋„คํŠธ์›Œํฌ๋ฅผ ์„ค์ •ํ•œ ํ›„ ์‹คํ–‰ํ•˜๋ฉด ๋˜๊ฒ ์ฃ ?

 

test1๊ณผ ๋™์ผํ•˜๊ฒŒ test2๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์—ฐ๊ฒฐ์ด ๋  ๊ฑฐ์—์š”.

 

ํ•˜๋‚˜์˜ Bridge Network์— ์—ฐ๊ฒฐ๋œ ๋‘ ๊ฐœ์˜ Container

 

์œ„์—์„œ ๋งํ–ˆ๋‹ค์‹œํ”ผ, ๋ธŒ๋ฆฌ์ง€ ๋„คํŠธ์›Œํฌ๋Š” ๋‹ค๋ฅธ ๋ธŒ๋ฆฌ์ง€ ๋„คํŠธ์›Œํฌ์™€์˜ ๊ฒฉ๋ฆฌ๊ฐ€ ๋œ๋‹ค๊ณ  ํ–ˆ๋Š”๋ฐ์š”.

๋งŒ์•ฝ, localnet์ด ์•„๋‹Œ othernet์„ ๋งŒ๋“ค์–ด ์ปจํ…Œ์ด๋„ˆ์— ์—ฐ๊ฒฐํ•œ๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ๊ตฌ์กฐ๊ฐ€ ๋ณด์—ฌ์ง€๊ฒ ์ฃ ?

 

 

2๊ฐœ์˜ ๋‹ค๋ฅธ Bridge Network

 

 

์„œ๋กœ ๋‹ค๋ฅธ ๋ธŒ๋ฆฌ์ง€๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— Container A์™€ Container B๋Š” ์„œ๋กœ ํ†ต์‹ ์„ ํ•  ์ˆ˜ ์—†๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

์ด์ œ Bridge network์— ๋Œ€ํ•ด ์ดํ•ด๊ฐ€ ๋๋‚˜์š”?

์กฐ๊ธˆ ๋ณต์žกํ•˜์ฃ ?

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ ๋ณต์žกํ•œ ๊ฑด ์ด์ œ ๋์ž…๋‹ˆ๋‹ค ใ…Žใ…Ž

 

 

 

Host

์œ„์—์„œ ์„ค๋ช…ํ•œ Bridge์€ ๋ณต์žกํ•œ ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

host ๋ชจ๋“œ๋Š” ๋ณด๋‹ค ๊ฐ„๋‹จํ•œ ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง‘๋‹ˆ๋‹ค.

 

host ๋ชจ๋“œ๋Š” ํ•˜๋‚˜์˜ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋‹ค๋ฅธ ์ปจํ…Œ์ด๋„ˆ์˜ ๋„คํŠธ์›Œํฌ ๊ตฌ์กฐ์— ๋„ฃ์€ ๋ชจ์Šต๊ณผ ๋น„์Šทํ•ฉ๋‹ˆ๋‹ค.

ํ˜ธ์ŠคํŠธ ๋ชจ๋“œ๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋„์ปค ํ˜ธ์ŠคํŠธ์˜ ๋„คํŠธ์›Œํฌ ๊ตฌ์กฐ์— ์ง์ ‘ ๋ฐฐ์น˜ํ•ฉ๋‹ˆ๋‹ค.

 

์ปจํ…Œ์ด๋„ˆ๋ฅผ ํ˜ธ์ŠคํŠธ์˜ ๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค์— ์ง์ ‘ ๋งคํ•‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํฌํŠธ๋ฅผ publishํ•˜๊ณ  exposeํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

์ฆ‰, ์ปจํ…Œ์ด๋„ˆ ํ”„๋กœ์„ธ์Šค๊ฐ€ ํ˜ธ์ŠคํŠธ์—์„œ lower level ํฌํŠธ๋ฅผ ์—ฌ๋Š” ๋“ฑ์˜ ํŠน์ • ๊ถŒํ•œ์ด ํ•„์š”ํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์‹œ์Šคํ…œ์— ๋” ๋งŽ์ด ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์ฃผ์˜ํ•˜์—ฌ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

์ปจํ…Œ์ด๋„ˆ์— host ๋ชจ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ, ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ํ˜ธ์ŠคํŠธ์˜ ๋„คํŠธ์›Œํ‚น ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋ฅผ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค.

์ฆ‰, ํ•ด๋‹น ์ปจํ…Œ์ด๋„ˆ์˜ ๋„คํŠธ์›Œํฌ ์Šคํƒ์ด ๋„์ปค ํ˜ธ์ŠคํŠธ์—์„œ ๋ถ„๋ฆฌ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๋•Œ๋ฌธ์— ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์ž์ฒด IP ์ฃผ์†Œ๋ฅผ ํ• ๋‹น๋ฐ›์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

 

์˜ˆ๋ฅผ ๋“ค์–ด ํฌํŠธ 80์— ๋ฐ”์ธ๋”ฉ๋˜๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ํ˜ธ์ŠคํŠธ ๋„คํŠธ์›Œํ‚น์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ

์ปจํ…Œ์ด๋„ˆ์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์€ ํ˜ธ์ŠคํŠธ IP ์ฃผ์†Œ์˜ ํฌํŠธ 80์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

ํ˜ธ์ŠคํŠธ ๋ชจ๋“œ ๋„คํŠธ์›Œํ‚น์„ ์‚ฌ์šฉํ•  ๋•Œ ์ปจํ…Œ์ด๋„ˆ์— ์ž์ฒด IP ์ฃผ์†Œ๊ฐ€ ์—†์œผ๋ฉด ํฌํŠธ ๋งคํ•‘์ด ์ ์šฉ๋˜์ง€ ์•Š์œผ๋ฉฐ 

-p, --publish,-P, --publish-all ์˜ต์…˜์ด ๋ฌด์‹œ๋˜๊ณ , ์•„๋ž˜์™€ ๊ฐ™์€ ๊ฒฝ๊ณ ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

WARNING: Published ports are discarded when using host network mode

 

 

 

None

None ๋„คํŠธ์›Œํฌ๋Š” ๋ง ๊ทธ๋Œ€๋กœ ์•„๋ฌด๊ฒƒ๋„ ์—†๋Š” ๋„คํŠธ์›Œํฌ๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

none ๋ชจ๋“œ๋Š” ๋„คํŠธ์›Œํฌ์˜ ์ •์˜๊ฐ€ ์ „ํ˜€ ์—†๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ •์˜ํ•˜๋Š” ๊ฒฝ์šฐ์— ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

 

None ๋„คํŠธ์›Œํฌ๋Š” ๋„์ปค๊ฐ€ ์„ค์น˜๋  ๋•Œ ๊ธฐ๋ณธ์œผ๋กœ ์„ค์ •๋˜๋Š” ๋„คํŠธ์›Œํฌ ์ค‘ ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค.

inspect ํ•ด๋ณด๋ฉด ์•„๋ฌด๋Ÿฐ ๋‚ด์šฉ์ด ์—†๋‹ค๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

$ docker network inspect none
[
    {
        "Name": "none",
        "Id": "21c84259960ac0c5c9a1721ff53501469abfc1b6400a74631c339b261f50c47e",
        "Created": "2021-11-16T10:40:56.880389185Z",
        "Scope": "local",
        "Driver": "null",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": []
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]

 

์œ„์— ๋‚ด์šฉ์„ ํ™•์ธํ•ด๋ณด๋ฉด Driver๋Š” null๋กœ ํ‘œ์‹œ๋˜๋Š”๋ฐ, ์ด๋Š” ์ด ๋„คํŠธ์›Œํฌ์˜ Driver๊ฐ€ ์—†์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

 

๊ทธ๋ ‡๋‹ค๋ฉด, ์ด๋Ÿฐ ์„ค์ •์„ ์™œ ํ• ๊นŒ์š”?

none ๋ชจ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด, ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ ๋„คํŠธ์›Œํฌ์˜ ์ตœ์†Œํ•œ์˜ ๊ฒƒ๋งŒ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

์‹ค์ œ๋กœ, ์ปจํ…Œ์ด๋„ˆ๋ฅผ none ๋ชจ๋“œ๋กœ ์‹คํ–‰ํ•˜๋ฉด ๋ฃจํ”„๋ฐฑ ์ธํ„ฐํŽ˜์ด์Šค์— ํ•ด๋‹นํ•˜๋Š” lo ๋ฅผ ์ œ์™ธํ•˜๊ณ  ์•„๋ฌด๊ฒƒ๋„ ์ƒ์„ฑ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

 

์‚ฌ์šฉ์ž๊ฐ€ ์ง์ ‘ ๋„คํŠธ์›Œํฌ๋ฅผ ๊ตฌ์„ฑ(์‚ฌ์šฉ์ž ์ •์˜ ์ธํ„ฐํŽ˜์ด์Šค ๋“ฑ)ํ•˜๊ณ ์ž ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๊ณค ํ•ฉ๋‹ˆ๋‹ค.

 

 

 

์ด๋ ‡๊ฒŒ docker network - 2 ํฌ์ŠคํŒ…์„ ๋งˆ๋ฌด๋ฆฌ ํ•˜๊ณ , 

๋‹ค์Œ ํฌ์ŠคํŒ…์—์„œ ๋“œ๋ผ์ด๋ฒ„์— ๋Œ€ํ•ด ๋” ์ž์„ธํžˆ ๋‹ค๋ฃจ๊ฒ ์Šต๋‹ˆ๋‹ค.

์ˆ˜์ •์‚ฌํ•ญ์ด๋‚˜ ์ž˜๋ชป๋œ ๋ถ€๋ถ„์€ ๋Œ“๊ธ€ ๋‚จ๊ฒจ์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ๐Ÿ™Œ๐Ÿป

 

 

์ฐธ๊ณ  ์ž๋ฃŒ

- O'Reilly - "Docker Deep Dive, The Docker Engine"

- O'Reilly - "Docker: Up & Running, 2nd Edition"

- O'Reilly - "Docker Networking Cookbook"

- understanding docker networking drivers use cases

- docker docs - network