*ETCD(Discovery Service)에서 IP 호스트 정보를 모두 인지하고 기록한다.


보통 다른 호스트와 통신이 필요할 때, 물리 네트워크 구간을 통해야 한다. 너무 어려움. 물리망을 마치 투명하게 만들 수 있다

=> 물리 어뎁터 기준 밑으로 물리망 (Underlay), 윗쪽은(Overlay)

=> Container들이 bridge network와 연동되어 요청을 직접 받는 것도 가능

=> VXLAN은 터널링의 표준?

=> Source / Destination을 지정할 수 있음!


*포트 설정 :

- EXPOSE의 정보를 통해서 HOST가 알아서 Container의 PORT를 찾아가게 된다.

- 외부 Client에서는 LB로 접근

- LB는 여러개 HOST로 연결 ( Port는 찾아서 자동 구성)

방법은 3가지 : 
1) -p <host port>:<container port>

2) -p <container port>

3) 호스트 머신에 동적으로 할당된 포트를 EXPOSE나 --expose를 사용하여 노출된 모든 포트에 매핑한다 : -P  


Kubernetes = 묶어서 관리하는 요소(Orchestration 도구)

Docker = Application 레벨에서만 생각

 




*Docker CP 명령어 


1
2
[root@host01-2 ~]# docker cp keen_newton:/etc/docker/registry/config.yml .
 
cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@host01-2 ~]# docker run -dp 80:80 -v $(pwd)/config.yml:/config.yml registry:2.5 config.yml
d60aad9dcefbd9f75511d176c51e65b9fdc4740f665aa98afed3e2e370de79cc
[root@host01-2 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                          NAMES
d60aad9dcefb        registry:2.5        "/entrypoint.sh conf…"   10 seconds ago      Up 9 seconds        0.0.0.0:80->80/tcp, 5000/tcp   flamboyant_joliot
[root@host01-2 ~]# docker exec -it d60aad9dcefb sh
/ # ls
bin            etc            media          run            tmp
config.yml     home           mnt            sbin           usr
dev            lib            proc           srv            var
entrypoint.sh  linuxrc        root           sys
/ # vi config.yml
/ # exit
[root@host01-2 ~]#
 
cs


*Docker Compose : 

docker compose = 단일 호스트

docker swarm (클러스터 관리툴)= 멀티 호스트


compose와 swarm을 연동할 수 있게 됐다..


* 표준 : yaml을 통해서 host에 배포? CLI는 단순 호출


*Docker compose 설치 : 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@host01-2 docker]# curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   617    0   617    0     0     93      0 --:--:--  0:00:06 --:--:--   150
100 10.3M  100 10.3M    0     0   374k      0  0:00:28  0:00:28 --:--:-- 1122k
[root@host01-2 docker]#
[root@host01-2 docker]# chmod +x /usr/local/bin/docker-compose
[root@host01-2 docker]# docker-compose version
docker-compose version 1.21.0, build 5920eb0
docker-py version: 3.2.1
CPython version: 3.6.5
OpenSSL version: OpenSSL 1.0.1t  3 May 2016
[root@host01-2 docker]#
 
cs


*YARM 파일 예시 : 

- XML과 유사, space로 구분, Tab은 안됨!!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
version: '3.3'
 
services:
   db:
     image: reg.cloud.com/mysql:5.7
     volumes:  #가지고 뜨는 볼륨
       - dbdata:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress
 
   wordpress:
     depends_on: #시작 함수를 해준다(db 함수가 먼저 실행된다)
       - db
     image: reg.cloud.com/wordpress:latest
     ports:
       - "8000:80" #포트 매핑 
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes:
    dbdata: #볼륨명
cs


*yml 파일 실행으로 wordpress 설치(결국 yml 파일을 잘 구성하는것이 중요)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
[root@host01-2 temp]# docker volume ls
DRIVER              VOLUME NAME
local               2042e79725f9ebcc220a00ec036065afe47f6a313c7fbc37424dc06707506024
local               3731b5e0372bf0b19e572f7022041069ef60631b68035fb044241a38f6de04de
local               4a35da8fe0f8f7855c92230679c18089d8734a66754c8e8523ac486a55cc4d05
local               5aaa3c1d276e0a539b0928437df457197be510c035cbfa8d34a7b7c345060335
local               6a37dd2b5eda64b880db3e122f3985e45bd249c94030d2db0d158691a45901eb
local               7177f41f8225923f8cde394fcd529b72ab9719a35fc1bd9723e2a6f2ab707681
local               7267f43dfed496a69277236002ab423079b871400ff68596856517e57291e7b3
local               9a8f8faa0acf42207fe6d8e6b24598edb2a3561616bf4f9abcc27295773ffa76
local               data
local               f4f24f0b97c0e0e3d739141827867affd43edd21b3667de33e7527a888b43f12
[root@host01-2 temp]# docker rm -rf volume
unknown shorthand flag: 'r' in -rf
See 'docker rm --help'.
[root@host01-2 temp]# docker rm -f volume
Error: No such container: volume
[root@host01-2 temp]# docker rm -f volume 2042e79725f9ebcc220a00ec036065afe47f6a313c7fbc37424dc06707506024 3731b5e0372bf0b19e572f7022041069ef60631b68035fb044241a38f6de04de
Error: No such container: volume
Error: No such container: 2042e79725f9ebcc220a00ec036065afe47f6a313c7fbc37424dc06707506024
Error: No such container: 3731b5e0372bf0b19e572f7022041069ef60631b68035fb044241a38f6de04de
[root@host01-2 temp]#
[root@host01-2 temp]#
[root@host01-2 temp]#
[root@host01-2 temp]#
[root@host01-2 temp]# docker-compose -f docker-compose.yml ^C
[root@host01-2 temp]# clear
[root@host01-2 temp]# ls
docker-compose.yml
[root@host01-2 temp]# docker-compose up -d
Creating network "temp_default" with the default driver
Creating volume "temp_dbdata" with default driver
Pulling db (reg.cloud.com/mysql:5.7)...
5.7: Pulling from mysql
Digest: sha256:a0423a7d021b7a7775f1d2db1014bd15fde029f538c1f8d97c9832aa4a25209f
Status: Downloaded newer image for reg.cloud.com/mysql:5.7
Pulling wordpress (reg.cloud.com/wordpress:latest)...
latest: Pulling from wordpress
85b1f47fba49: Already exists
d8204bc92725: Pull complete
92fc16bb18e4: Pull complete
31098e61b2ae: Pull complete
f6ae64bfd33d: Pull complete
003c1818b354: Pull complete
a6fd4aeb32ad: Pull complete
a094df7cedc1: Pull complete
e3bf6fc1a51d: Pull complete
ad235c260360: Pull complete
edbf48bcbd7e: Pull complete
fd6ae81d5745: Pull complete
69838fd876d6: Pull complete
3186ebffd72d: Pull complete
b24a415ea2c0: Pull complete
225bda14ea90: Pull complete
fc0ad3550a92: Pull complete
0e4600933a8c: Pull complete
Digest: sha256:5b3b36db3c19d5b8c6ded6facec4daac57fe2ea1879351a2e65ac8919cea37ce
Status: Downloaded newer image for reg.cloud.com/wordpress:latest
Creating temp_db_1 ... done
Creating temp_wordpress_1 ... done
[root@host01-2 temp]# docker-comose ps
-bash: docker-comose: command not found
[root@host01-2 temp]# docker-compose ps
      Name                    Command               State          Ports
--------------------------------------------------------------------------------
temp_db_1          docker-entrypoint.sh mysqld      Up      3306/tcp
temp_wordpress_1   docker-entrypoint.sh apach ...   Up      0.0.0.0:8000->80/tcp
[root@host01-2 temp]# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
76d13a20d92c        bridge              bridge              local
a4bddc4df10b        host                host                local
1e75b30aa8ac        isolated_nw         bridge              local
e9ef483dde2d        none                null                local
02e52b7344b7        temp_default        bridge              local
efe418b38219        test                bridge              local
[root@host01-2 temp]# docker volum ls
docker: 'volum' is not a docker command.
See 'docker --help'
[root@host01-2 temp]# docker volume ls
DRIVER              VOLUME NAME
local               2042e79725f9ebcc220a00ec036065afe47f6a313c7fbc37424dc06707506024
local               3731b5e0372bf0b19e572f7022041069ef60631b68035fb044241a38f6de04de
local               4a35da8fe0f8f7855c92230679c18089d8734a66754c8e8523ac486a55cc4d05
local               5aaa3c1d276e0a539b0928437df457197be510c035cbfa8d34a7b7c345060335
local               67e959ee45f5221450510cbd82e314be628275fdfc34729002ed667c026e94b8
local               6a37dd2b5eda64b880db3e122f3985e45bd249c94030d2db0d158691a45901eb
local               7177f41f8225923f8cde394fcd529b72ab9719a35fc1bd9723e2a6f2ab707681
local               7267f43dfed496a69277236002ab423079b871400ff68596856517e57291e7b3
local               9a8f8faa0acf42207fe6d8e6b24598edb2a3561616bf4f9abcc27295773ffa76
local               data
local               f4f24f0b97c0e0e3d739141827867affd43edd21b3667de33e7527a888b43f12
local               temp_dbdata
[root@host01-2 temp]# ls /var/lib/docker/volumse/lab_dbdata/_data/-l
ls: cannot access /var/lib/docker/volumse/lab_dbdata/_data/-l: No such file or directory
[root@host01-2 temp]# ls /var/lib/docker/volumse/lab_dbdata/_data/ -l
ls: cannot access /var/lib/docker/volumse/lab_dbdata/_data/: No such file or directory
[root@host01-2 temp]# ls /var/lib/docker/volumes/temp_dbdata/_data/ -l
total 188488
-rw-r-----1 polkitd ssh_keys       56 May 24 17:19 auto.cnf
-rw-------1 polkitd ssh_keys     1675 May 24 17:19 ca-key.pem
-rw-r--r--1 polkitd ssh_keys     1107 May 24 17:19 ca.pem
-rw-r--r--1 polkitd ssh_keys     1107 May 24 17:19 client-cert.pem
-rw-------1 polkitd ssh_keys     1679 May 24 17:19 client-key.pem
-rw-r-----1 polkitd ssh_keys     1321 May 24 17:19 ib_buffer_pool
-rw-r-----1 polkitd ssh_keys 79691776 May 24 17:21 ibdata1
-rw-r-----1 polkitd ssh_keys 50331648 May 24 17:21 ib_logfile0
-rw-r-----1 polkitd ssh_keys 50331648 May 24 17:19 ib_logfile1
-rw-r-----1 polkitd ssh_keys 12582912 May 24 17:21 ibtmp1
drwxr-x---2 polkitd ssh_keys     4096 May 24 17:19 mysql
drwxr-x---2 polkitd ssh_keys     8192 May 24 17:19 performance_schema
-rw-------1 polkitd ssh_keys     1679 May 24 17:19 private_key.pem
-rw-r--r--1 polkitd ssh_keys      451 May 24 17:19 public_key.pem
-rw-r--r--1 polkitd ssh_keys     1107 May 24 17:19 server-cert.pem
-rw-------1 polkitd ssh_keys     1675 May 24 17:19 server-key.pem
drwxr-x---2 polkitd ssh_keys     8192 May 24 17:19 sys
drwxr-x---2 polkitd ssh_keys     4096 May 24 17:21 wordpress
[root@host01-2 temp]# docker-compose down
Stopping temp_wordpress_1 ... done
Stopping temp_db_1        ... done
Removing temp_wordpress_1 ... done
Removing temp_db_1        ... done
Removing network temp_default
[root@host01-2 temp]# docker-compose ps
Name   Command   State   Ports
------------------------------
[root@host01-2 temp]# docker volume ls
DRIVER              VOLUME NAME
local               2042e79725f9ebcc220a00ec036065afe47f6a313c7fbc37424dc06707506024
local               3731b5e0372bf0b19e572f7022041069ef60631b68035fb044241a38f6de04de
local               4a35da8fe0f8f7855c92230679c18089d8734a66754c8e8523ac486a55cc4d05
local               5aaa3c1d276e0a539b0928437df457197be510c035cbfa8d34a7b7c345060335
local               67e959ee45f5221450510cbd82e314be628275fdfc34729002ed667c026e94b8
local               6a37dd2b5eda64b880db3e122f3985e45bd249c94030d2db0d158691a45901eb
local               7177f41f8225923f8cde394fcd529b72ab9719a35fc1bd9723e2a6f2ab707681
local               7267f43dfed496a69277236002ab423079b871400ff68596856517e57291e7b3
local               9a8f8faa0acf42207fe6d8e6b24598edb2a3561616bf4f9abcc27295773ffa76
local               data
local               f4f24f0b97c0e0e3d739141827867affd43edd21b3667de33e7527a888b43f12
local               temp_dbdata
[root@host01-2 temp]# docker-compose up -d
Creating network "temp_default" with the default driver
Creating temp_db_1 ... done
Creating temp_wordpress_1 ... done
[root@host01-2 temp]#
 
cs






+ Recent posts