linux kill: kill -9 PID (해당 프로세스 강제종료)
container 간 통신: API 통신(개별적인 application 정보가 있기 때문에 그것을 통해 서로 통신)
Master DB - 서브 DB
load balancer
kevin@hostos1:~$ brctl show
Command 'brctl' not found, but can be installed with:
sudo apt install bridge-utils
kevin@hostos1:~$ sudo apt install bridge-utils
.
.
.
kevin@hostos1:~$ brctl show
bridge name bridge id STP enabled interfaces
docker0 8000.02422861f0c3 no veth1c8a77b
kevin@hostos1:~$ docker network create -d bridge web-net
e41ae922e9737a90b42a615ae2deb60910307c835439191c8b417ca23881ccb1
kevin@hostos1:~$ docker run --net=web-net -it --name=net-check1 ubuntu:14.04 bash
kevin@hostos1:~$ docker run --net=web-net -it --name=net-check2 ubuntu:14.04 bash
kevin@hostos1:~$ docker network create --driver bridge --subnet 172.30.1.0/24ange 172.30.1.0/24 --gateway 172.30.1.1 vswitch-net
kevin@hostos1:~$ docker run -it --name=appsrv1 --net=app-service ubuntu:14.04 bash
kevin@hostos1:~$ docker run -it --name=appsrv2 --net=app-service ubuntu:14.04 bash
root@153d63cda843:/# ping -c 2 192.168.56.101
PING 192.168.56.101 (192.168.56.101) 56(84) bytes of data.
64 bytes from 192.168.56.101: icmp_seq=1 ttl=64 time=0.125 ms
64 bytes from 192.168.56.101: icmp_seq=2 ttl=64 time=0.108 ms
root@153d63cda843:/# ping -c 5 appsrv2
PING appsrv2 (172.19.0.3) 56(84) bytes of data.
64 bytes from 153d63cda843 (172.19.0.3): icmp_seq=1 ttl=64 time=0.028 ms
64 bytes from 153d63cda843 (172.19.0.3): icmp_seq=2 ttl=64 time=0.078 ms
64 bytes from 153d63cda843 (172.19.0.3): icmp_seq=3 ttl=64 time=0.069 ms
64 bytes from 153d63cda843 (172.19.0.3): icmp_seq=4 ttl=64 time=0.076 ms
64 bytes from 153d63cda843 (172.19.0.3): icmp_seq=5 ttl=64 time=0.093 ms
host는 /etc/hosts에 host로 등록되어 있어서 ping 전송이 가능하지만
어떻게 컨테이너 이름으로 ping 전송이 가능할까 ?
▶ DNS 기능 중 하나
docker network create --driver bridge --subnet 172.30.1.0/24 --ip-range 172.30.1.0/24 --gateway 172.30.1.1 vswitch-net
kevin@hostos1:~$ docker run --net=vswitch-net -itd --name=net1 ubuntu:14.04
c687e635aaaf52b1ad17d652c764b3fa59e99ad6f2ac24aac7a1a6c372333813
kevin@hostos1:~$ docker run --net=vswitch-net -itd --name=net2 --ip 172.30.1.100 ubuntu:14.04
24fadd4f27a796631e15d0c3a6a5b48b943ab1d274301eeb9dff1e5adbb5f289
= switch (switch 장비와 같은 역할을 함)
1) docker container self LB (docker container에 내장된 DNS server(service)로 구현
--net-alias
: target group (workload(트래픽)를 받을 서버(컨테이너)의 그룹2) nginx container 를 proxy로 전환하여 LB로 구성
--- C1
외부 ------- [nginx LB] --- C2
--- C3
3) LAB
kevin@hostos1:~/LABs$ docker network create \
> --driver bridge \
> --subnet 172.200.1.0/24 \
> --ip-range 172.200.1.0/24 \
> --gateway 172.200.1.1 \
> netlb
f2548fe02dd06933ce8437b32a753ed87acb68c6a7c84d93bec7506fd65dd4a9
kevin@hostos1:~/LABs$ docker network ls
NETWORK ID NAME DRIVER SCOPE
b60856d177f7 app-service bridge local
3449ec5e77e1 bridge bridge local
f08ed86039aa host host local
f2548fe02dd0 netlb bridge local
7897dc8cebd4 none null local
e6753b842d2d vswitch-net bridge local
e41ae922e973 web-net bridge local
kevin@hostos1:~/LABs$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 100 0 0 enp0s 3
default _gateway 0.0.0.0 UG 20101 0 0 enp0s 8
10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s 3
link-local 0.0.0.0 255.255.0.0 U 1000 0 0 enp0s 3
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docke r0
172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-e4 1ae922e973
172.19.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-b6 0856d177f7
172.30.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-e6 753b842d2d
172.200.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-f2 548fe02dd0
192.168.56.0 0.0.0.0 255.255.255.0 U 101 0 0 enp0s
kevin@hostos1:~$ docker run -itd --name=lb-test1 --net=netlb --net-alias=tg-net ubun
ca6f35b9181109db8730f50b5834ca32fbb5fdf9d3c78e3352620b0a0478e42f
kevin@hostos1:~$ docker run -itd --name=lb-test2 --net=netlb --net-alias=tg-net ubun
263e2f37ae392393525faa631489f23bbf7bf052646925554865c528e98eb1d4
kevin@hostos1:~$ docker run -itd --name=lb-test3 --net=netlb --net-alias=tg-net ubun
0be3da2257a00c0533f8299892a5d424f83d392a9ce99313aa9bdfaf6d21ead1
kevin@hostos1:~$ docker inspect lb-test1 | grep IPA
"SecondaryIPAddresses": null,
"IPAddress": "",
"IPAMConfig": null,
"IPAddress": "172.200.1.2",
kevin@hostos1:~$ docker inspect lb-test2 | grep IPA
"SecondaryIPAddresses": null,
"IPAddress": "",
"IPAMConfig": null,
"IPAddress": "172.200.1.3",
kevin@hostos1:~$ docker inspect lb-test3 | grep IPA
"SecondaryIPAddresses": null,
"IPAddress": "",
"IPAMConfig": null,
"IPAddress": "172.200.1.4",
kevin@hostos1:~$ docker run -it --name=frontend --net=netlb ubuntu:14.04 bash
kevin@hostos1:~$ docker run -itd --name=lb-test4 --net=netlb --net-alias=tg-net ubuntu:14.04
HAProxy