<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[刘新修]]></title> 
<link>http://pic1.liuxinxiu.com:80/index.php</link> 
<description><![CDATA[刘新修的个人博客 (Liuxinxiu'S Blog)]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[刘新修]]></copyright>
<item>
<link>http://pic1.liuxinxiu.com:80/Docker/</link>
<title><![CDATA[Docker重大更新，2017-03-02版本升至17.03，包名仓库全换]]></title> 
<author>刘新修 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[虚拟化]]></category>
<pubDate>Mon, 12 Jun 2017 06:03:10 +0000</pubDate> 
<guid>http://pic1.liuxinxiu.com:80/Docker/</guid> 
<description>
<![CDATA[ 
	<p><span style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">3月2日，Docker 官方发布了一篇 </span><a href="https://blog.docker.com/2017/03/docker-enterprise-edition/" target="_blank" style="color: rgb(34, 34, 156); text-decoration: none; font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">blog</a><span style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);"> ，宣布企业版到来。版本也从1.13.x一跃到17.03。</span><br style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);" /><br style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);" /><span style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">之后，Docker 会每月发布一个 edge 版本(17.03, 17.04, 17.05...)，每三个月发布一个 stable 版本(17.03, 17.06, 17.09...)，企业版(EE) 和 stable 版本号保持一致，但每个版本提供一年维护。</span><br style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);" /><br style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);" /><span style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">Docker 的 Linux 发行版的软件仓库也从以前的</span><a href="https://apt.dockerproject.org/" target="_blank" style="color: rgb(34, 34, 156); text-decoration: none; font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">https://apt.dockerproject.org</a><span style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);"> / </span><a href="https://yum.dockerproject.org/" target="_blank" style="color: rgb(34, 34, 156); text-decoration: none; font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">https://yum.dockerproject.org</a><span style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);"> 变更为目前的 </span><a href="https://download.docker.com/" target="_blank" style="color: rgb(34, 34, 156); text-decoration: none; font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">https://download.docker.com/</a><span style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">。软件包名变更为 docker-ce(社区版) 和 docker-ee(企业版)。</span><br style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);" /><br style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);" /><span style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">旧的仓库和包名(docker-engine)依旧可以使用，但不确定什么时候会被废弃，docker-engine 的版本号也变成了17.03.0~ce-0这种的版本号。</span><br style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);" /><br style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);" /><span style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">Docker v17.03.0-ce 版本更新内容和下载地址请查看</span><a href="https://github.com/docker/docker/releases" target="_blank" style="color: rgb(34, 34, 156); text-decoration: none; font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">发行日志</a><span style="font-family: Geneva, Arial, Helvetica, sans-serif; background-color: rgb(249, 249, 249);">。</span></p><p><span style="color: rgb(255, 0, 0);"><strong>Docker的网络模式和跨主机通信(Docker的四种网络模式Bridge模式)</strong></span></p><p>当Docker进程启动时，会在主机上创建一个名为docker0...</p><p>Docker的四种网络模式</p><p><strong>1. Bridge模式</strong></p><p>当Docker进程启动时，会在主机上创建一个名为docker0的虚拟网桥，此主机上启动的Docker容器会连接到这个虚拟网桥上。虚拟网桥的工作方式和物理交换机类似，这样主机上的所有容器就通过交换机连在了一个二层网络中。</p><p>从docker0子网中分配一个IP给容器使用，并设置docker0的IP地址为容器的默认网关。在主机上创建一对虚拟网卡veth pair设备，Docker将veth pair设备的一端放在新创建的容器中，并命名为eth0（容器的网卡），另一端放在主机中，以vethxxx这样类似的名字命名，并将这个网络设备加入到docker0网桥中。可以通过brctl show命令查看。</p><p>bridge模式是docker的默认网络模式，不写--net参数，就是bridge模式。使用docker run -p时，docker实际是在iptables做了DNAT规则，实现端口转发功能。可以使用iptables -t nat -vnL查看。</p><p>&nbsp;</p><p>bridge模式如下图所示：</p><p><a href="http://at.liuxinxiu.com/2017/06/image/docker-01.png" target="_blank"><img src="http://at.liuxinxiu.com/2017/06/image/docker-01.png" width="800" height="919" alt="" /></a>演示：</p><div class="codeText"><div class="codeHead">C#代码</div><ol start="1" class="dp-c"><li class="alt"><span><span class="preprocessor">#docker&nbsp;run&nbsp;-tid&nbsp;--net=bridge&nbsp;--name&nbsp;docker_bri1&nbsp;ubuntu-base:v3</span><span>&nbsp;&nbsp;</span></span></li><li><span><span class="preprocessor">#docker&nbsp;run&nbsp;-tid&nbsp;--net=bridge&nbsp;--name&nbsp;docker_bri2&nbsp;ubuntu-base:v3</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;</span></li><li><span><span class="preprocessor">#brctl&nbsp;show</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="preprocessor">#docker&nbsp;exec&nbsp;-ti&nbsp;docker_bri1&nbsp;/bin/bash</span><span>&nbsp;&nbsp;</span></span></li><li><span><span class="preprocessor">#docker&nbsp;exec&nbsp;-ti&nbsp;docker_bri1&nbsp;/bin/bash</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;</span></li><li><span><span class="preprocessor">#ifconfig&nbsp;&ndash;a</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="preprocessor">#route&nbsp;&ndash;n</span><span>&nbsp;&nbsp;</span></span></li></ol></div><p><strong>2. Host模式</strong></p><p>如果启动容器的时候使用host模式，那么这个容器将不会获得一个独立的Network Namespace，而是和宿主机共用一个Network Namespace。容器将不会虚拟出自己的网卡，配置自己的IP等，而是使用宿主机的IP和端口。但是，容器的其他方面，如文件系统、进程列表等还是和宿主机隔离的。</p><p>Host模式如下图所示：</p><p><a href="http://at.liuxinxiu.com/2017/06/image/docker-02.png" target="_blank"><img src="http://at.liuxinxiu.com/2017/06/image/docker-02.png" width="800" height="900" alt="" /></a></p><p>演示：</p><div class="codeText"><div class="codeHead">C#代码</div><ol start="1" class="dp-c"><li class="alt"><span><span class="preprocessor">#docker&nbsp;run&nbsp;-tid&nbsp;--net=host&nbsp;--name&nbsp;docker_host1&nbsp;ubuntu-base:v3</span><span>&nbsp;&nbsp;</span></span></li><li><span><span class="preprocessor">#docker&nbsp;run&nbsp;-tid&nbsp;--net=host&nbsp;--name&nbsp;docker_host2&nbsp;ubuntu-base:v3</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;</span></li><li><span><span class="preprocessor">#docker&nbsp;exec&nbsp;-ti&nbsp;docker_host1&nbsp;/bin/bash</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="preprocessor">#docker&nbsp;exec&nbsp;-ti&nbsp;docker_host1&nbsp;/bin/bash</span><span>&nbsp;&nbsp;</span></span></li><li><span>&nbsp;</span></li><li class="alt"><span><span class="preprocessor">#ifconfig&nbsp;&ndash;a</span><span>&nbsp;&nbsp;</span></span></li><li><span><span class="preprocessor">#route&nbsp;&ndash;n</span><span>&nbsp;&nbsp;</span></span></li></ol></div><p><strong>3. Container模式</strong></p><p>这个模式指定新创建的容器和已经存在的一个容器共享一个 Network Namespace，而不是和宿主机共享。新创建的容器不会创建自己的网卡，配置自己的 IP，而是和一个指定的容器共享 IP、端口范围等。同样，两个容器除了网络方面，其他的如文件系统、进程列表等还是隔离的。两个容器的进程可以通过 lo 网卡设备通信。</p><p>Container模式示意图：</p><p><a href="http://at.liuxinxiu.com/2017/06/image/docker-03.png" target="_blank"><img src="http://at.liuxinxiu.com/2017/06/image/docker-03.png" width="800" height="914" alt="" /></a></p><p>演示：</p><div class="codeText"><div class="codeHead">C#代码</div><ol start="1" class="dp-c"><li class="alt"><span><span class="preprocessor">#docker&nbsp;run&nbsp;-tid&nbsp;--net=container:docker_bri1&nbsp;--name&nbsp;docker_con1&nbsp;ubuntu-base:v3</span><span>&nbsp;&nbsp;</span></span></li><li><span>&nbsp;</span></li><li class="alt"><span><span class="preprocessor">#docker&nbsp;exec&nbsp;-ti&nbsp;docker_con1&nbsp;/bin/bash</span><span>&nbsp;&nbsp;</span></span></li><li><span><span class="preprocessor">#docker&nbsp;exec&nbsp;-ti&nbsp;docker_bri1&nbsp;/bin/bash</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;</span></li><li><span><span class="preprocessor">#ifconfig&nbsp;&ndash;a</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="preprocessor">#route&nbsp;-n</span><span>&nbsp;&nbsp;</span></span></li></ol></div><p><strong>4. None模式</strong></p><p>使用none模式，Docker容器拥有自己的Network Namespace，但是，并不为Docker容器进行任何网络配置。也就是说，这个Docker容器没有网卡、IP、路由等信息。需要我们自己为Docker容器添加网卡、配置IP等。</p><p>Node模式示意图:</p><p><a href="http://at.liuxinxiu.com/2017/06/image/docker-04.png" target="_blank"><img src="http://at.liuxinxiu.com/2017/06/image/docker-04.png" width="800" height="934" alt="" /></a></p><p>演示：</p><div class="codeText"><div class="codeHead">C#代码</div><ol start="1" class="dp-c"><li class="alt"><span><span class="preprocessor">#docker&nbsp;run&nbsp;-tid&nbsp;--net=none&nbsp;--name&nbsp;docker_non1&nbsp;ubuntu-base:v3</span><span>&nbsp;&nbsp;</span></span></li><li><span><span class="preprocessor">#docker&nbsp;exec&nbsp;-ti&nbsp;docker_non1&nbsp;/bin/bash</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;</span></li><li><span><span class="preprocessor">#ifconfig&nbsp;&ndash;a</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="preprocessor">#route&nbsp;-n</span><span>&nbsp;&nbsp;</span></span></li></ol></div><p>跨主机通信</p><p>Docker默认的网络环境下，单台主机上的Docker容器可以通过docker0网桥直接通信，而不同主机上的Docker容器之间只能通过在主机上做端口映射进行通信。这种端口映射方式对很多集群应用来说极不方便。如果能让Docker容器之间直接使用自己的IP地址进行通信，会解决很多问题。按实现原理可分别直接路由方式、桥接方式（如pipework）、Overlay隧道方式（如flannel、ovs+gre）等。</p><p>直接路由</p><p>通过在Docker主机上添加静态路由实现跨宿主机通信：</p><p><a href="http://at.liuxinxiu.com/2017/06/image/docker-05.png" target="_blank"><img src="http://at.liuxinxiu.com/2017/06/image/docker-05.png" width="800" height="420" alt="" /></a></p><p><strong>Pipework</strong></p><p>Pipework是一个简单易用的Docker容器网络配置工具。由200多行shell脚本实现。通过使用ip、brctl、ovs-vsctl等命令来为Docker容器配置自定义的网桥、网卡、路由等。</p><p>使用新建的bri0网桥代替缺省的docker0网桥</p><p>bri0网桥与缺省的docker0网桥的区别：bri0和主机eth0之间是veth pair</p>
]]>
</description>
</item><item>
<link>http://pic1.liuxinxiu.com:80/Docker/#blogcomment</link>
<title><![CDATA[[评论] Docker重大更新，2017-03-02版本升至17.03，包名仓库全换]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://pic1.liuxinxiu.com:80/Docker/#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>