-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15910177614091.html
232 lines (201 loc) · 15.2 KB
/
15910177614091.html
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!doctype html>
<html lang="zh-cn">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1" />
<title>
同主机下容器间通信 -
</title>
<meta name="keywords" content="" />
<meta name="twitter:card" content="summary_large_image" />
<meta property="og:url" content="15910177614091.html" />
<meta property="og:title" content="同主机下容器间通信" />
<meta property="og:description" content="同主机下容器间通信" />
<meta property="og:site_name" content="" />
<link href="atom.xml" rel="alternate" title="" type="application/atom+xml">
<script src="https://cdn.bootcss.com/moment.js/2.24.0/moment.min.js"></script>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="asset/style.css">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div class="container">
<div class="head">
<div class="row">
<div class="col-md-12">
<div class="blogname"></div>
<nav>
<div class="item"><a target="self" href="index.html">Home</a></div>
<div class="item"><a target="_self" href="archives.html">Archives</a></div>
</nav>
</div>
</div>
</div>
<hr>
</div> <div class="container" id="post">
<div class="article huge">
<div class="featureimg" style="background-image: url('asset/defaultfeaimg.jpg')"></div>
<img src="" style="display: none;" class="featureimgforexternal">
<div class="timeGTM" style="display:none;">2020-06-01T21:22:41+08:00</div>
<div class="row content">
<div class="col-md-2"></div>
<div class="col-md-10 main">
<div class="row">
<div class="col-md-10">
<div class="post">
<div class="headline"><a href="15910177614091.html">同主机下容器间通信</a></div>
<div class="meta"><span class="time">$[timeformat('2020-06-01T21:22:41+08:00')]</span><br><span class="tags"></span></div>
<div class="body">
<p><img src="media/15901149429220/15901264946705.png" alt=""/></p>
<h4 id="toc_0">启动第一个container</h4>
<pre><code class="language-log">casa@ce:~$ docker run -d --name agent-1 casa-vccap-host-agent:v1.0.1
8c5570dbc89f5d0e8b69ca4d41f0aa0ec2a488581c7a287c5c94d6f55972107c
casa@ce:~$ docker exec -it agent-1 /bin/sh
/ #
/ #
/ # ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:03
inet addr:172.17.0.3 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:648 (648.0 B) TX bytes:648 (648.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
/ # route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.1 0.0.0.0 UG 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
/ #
</code></pre>
<h4 id="toc_1">启动第二个container</h4>
<pre><code class="language-log">casa@ce:~$ docker run -d --name agent-2 casa-vccap-host-agent:v1.0.1
46fb7e364eaec177a3c79395dd533f156d7a7f9dba5a8e67403e3574f892e20d
casa@ce:~$ docker exec -it agent-2 /bin/sh
/ # ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:04
inet addr:172.17.0.4 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:648 (648.0 B) TX bytes:648 (648.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
/ # route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.1 0.0.0.0 UG 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
/ #
/ # ping 172.17.0.3
PING 172.17.0.3 (172.17.0.3): 56 data bytes
64 bytes from 172.17.0.3: seq=0 ttl=64 time=0.178 ms
64 bytes from 172.17.0.3: seq=1 ttl=64 time=0.079 ms
^C
--- 172.17.0.3 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.079/0.128/0.178 ms
/ #
</code></pre>
<h4 id="toc_2">通过iptable跟踪packet</h4>
<pre><code class="language-bash">sudo modprobe ipt_LOG
sudo iptables -t raw -A PREROUTING -p icmp -j TRACE
sudo iptables -t raw -A PREROUTING -p icmp -j LOG --log-prefix icmp
</code></pre>
<pre><code class="language-log">May 22 13:41:51 ce kernel: icmpIN=docker0 OUT= PHYSIN=vethba02d22 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: raw:PREROUTING:policy:3 IN=docker0 OUT= PHYSIN=vethba02d22 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: mangle:PREROUTING:policy:1 IN=docker0 OUT= PHYSIN=vethba02d22 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: nat:PREROUTING:rule:1 IN=docker0 OUT= PHYSIN=vethba02d22 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: nat:KUBE-SERVICES:return:8 IN=docker0 OUT= PHYSIN=vethba02d22 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: nat:PREROUTING:policy:3 IN=docker0 OUT= PHYSIN=vethba02d22 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: mangle:FORWARD:policy:1 IN=docker0 OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:FORWARD:rule:1 IN=docker0 OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:KUBE-FORWARD:return:4 IN=docker0 OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:FORWARD:rule:2 IN=docker0 OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:DOCKER-ISOLATION:return:1 IN=docker0 OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:FORWARD:rule:3 IN=docker0 OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:DOCKER:return:1 IN=docker0 OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:FORWARD:rule:6 IN=docker0 OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 MAC=02:42:ac:11:00:03:02:42:ac:11:00:04:08:00 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: mangle:POSTROUTING:policy:1 IN= OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: nat:POSTROUTING:rule:1 IN= OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: nat:KUBE-POSTROUTING:return:2 IN= OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: nat:POSTROUTING:policy:7 IN= OUT=docker0 PHYSIN=vethba02d22 PHYSOUT=vethe6fe429 SRC=172.17.0.4 DST=172.17.0.3 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=45643 DF PROTO=ICMP TYPE=8 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: icmpIN=docker0 OUT= PHYSIN=vethe6fe429 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: raw:PREROUTING:policy:3 IN=docker0 OUT= PHYSIN=vethe6fe429 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: mangle:PREROUTING:policy:1 IN=docker0 OUT= PHYSIN=vethe6fe429 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: mangle:FORWARD:policy:1 IN=docker0 OUT=docker0 PHYSIN=vethe6fe429 PHYSOUT=vethba02d22 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:FORWARD:rule:1 IN=docker0 OUT=docker0 PHYSIN=vethe6fe429 PHYSOUT=vethba02d22 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:KUBE-FORWARD:return:4 IN=docker0 OUT=docker0 PHYSIN=vethe6fe429 PHYSOUT=vethba02d22 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:FORWARD:rule:2 IN=docker0 OUT=docker0 PHYSIN=vethe6fe429 PHYSOUT=vethba02d22 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:DOCKER-ISOLATION:return:1 IN=docker0 OUT=docker0 PHYSIN=vethe6fe429 PHYSOUT=vethba02d22 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:FORWARD:rule:3 IN=docker0 OUT=docker0 PHYSIN=vethe6fe429 PHYSOUT=vethba02d22 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:DOCKER:return:1 IN=docker0 OUT=docker0 PHYSIN=vethe6fe429 PHYSOUT=vethba02d22 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: filter:FORWARD:rule:4 IN=docker0 OUT=docker0 PHYSIN=vethe6fe429 PHYSOUT=vethba02d22 MAC=02:42:ac:11:00:04:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
May 22 13:41:51 ce kernel: TRACE: mangle:POSTROUTING:policy:1 IN= OUT=docker0 PHYSIN=vethe6fe429 PHYSOUT=vethba02d22 SRC=172.17.0.3 DST=172.17.0.4 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=53618 PROTO=ICMP TYPE=0 CODE=0 ID=6400 SEQ=0
</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
let post = new Vue({
el: '#post',
data: {
hidelikecoin: ''
},
methods: {
timeformat(raw) {
return moment(raw).format("YYYY 年 MM 月 DD 日");
}
},
delimiters: ['$[', ']']
})
</script> <div class="container">
<hr>
<div class="footer" id="footer">
<div class="slogan">Let's tessellate.</div>
<div class="meta">
<p>「」使用 <a href="https://zh.mweb.im/" target="_blank">MWeb</a> 和 <a href="https://github.com/Astrian/reflect-white-mweb-theme" target="_blank">Reflect White</a> 搭建。</p>
</div>
</div>
<script>
let footer = new Vue({
el: '#footer',
data: {
message: 'hello'
},
delimiters: ['$[', ']']
})
</script>
</div>
</div>
</body>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</html>