Docker Network
650) this.width=650; "Src=" http://img.blog.csdn.net/20160202172332148?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/center "Width=" 803 "height=" 466 "style=" border:none; "/>
The Docker network is typically made up of a veth{id} on the host hosts a virtual NIC and a eth0 one by one mapping inside a container
, we can see that a default Docker0 bridge has been created on the host, the bridge responsible for forwarding the data stream between different veth to realize the IO of the network. Bridge Bridge (DOCKER0) uses the RFC1918 private network, which is responsible for assigning IP to each container.
650) this.width=650; "src=" http://img.blog.csdn.net/20160202172402399 "width=" 803 "height=" 418 "style=" Border:none; " />
Docker's network mode
650) this.width=650; "Src=" http://img.blog.csdn.net/20160202172618734?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/center "Width=" 803 "height=" 458 "style=" border:none; "/>
The network mode of Docker consists of four ways:
Understanding the four network patterns can be analogous to the different network settings of the VMware workstation that we often use.
Bridging Mode : Equivalent to the entire host OS, and create a Docker bridge, the entire bridge has a separate IP segment, then the bridge mode of the different container network is the Network Bridge.
As shown below: Docker0 Bridge is 172.17.0.1, then the container instance that starts is 172.17.0.2 ....
[HTML] view plain copy print? 650) this.width=650; "src=" Https://code.csdn.net/assets/CODE_ico.png "width=" "height=" "alt=" on Code view Style= "Border:none;"/>650) this.width=650; "src=" Https://code.csdn.net/assets/ico_fork.svg "width=" 12 "Height=" "alt=" is derived to My code slice "style=" border:none; "/>
[Email protected]:~# ifconfig
Docker0 Link encap:ethernet HWaddr 02:42:17:fb:75:74
inet addr:172.17.0.1 bcast:0.0.0.0 mask:255.255.0.0
Up broadcast multicast mtu:1500 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:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Eth0 Link encap:ethernet HWaddr 00:0c:29:8a:ff:d8
inet addr:192.168.12.107 bcast:192.168.12.255 mask:255.255.255.0
Inet6 ADDR:FE80::20C:29FF:FE8A:FFD8/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:853 errors:0 dropped:0 overruns:0 frame:0
TX packets:390 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:85058 (85.0 KB) TX bytes:62727 (62.7 KB)
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:32 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2368 (2.3 kb) TX bytes:2368 (2.3 kb)
650) this.width=650; "src=" http://img.blog.csdn.net/20160202174315694 "style=" border:none; "/>
Host Mode : In fact, the so-called container network is consistent with the host OS network, and in doing so, add the command parameter:--net host
Host represents the use of the host's network stack, the host host does not create a Veth virtual network card mapping.
650) this.width=650; "src=" http://img.blog.csdn.net/20160202174807184 "style=" border:none; "/>
In general, we access host-mode container objects by accessing the hosts ip+ port.
650) this.width=650; "src=" http://img.blog.csdn.net/20160202175026112 "width=" 803 "height=" style= "Border:none" />
Of course, if you consider the need for security, we can do port mapping.
Docker allows the internal container service port to be exposed by using port mapping
Use the-p parameter to specify the internal port of the container that needs to be exposed, and Docker automatically assigns (49000-49900) the port on one host to its mapping without specifying the corresponding port of the specific host
Use the-p parameter to indicate that all ports specified by expose are exposed in the image
650) this.width=650; "src=" http://img.blog.csdn.net/20160202175318613 "width=" 803 "height=" style= "Border:none" />
Container mode : And the role of the bridge through a container network, the other container network, and the container in the same network.
Container:{name|id}, use a different container network stack
Standalone Mode : All container networks within the host are isolated, and we can The none parameter, which indicates that the network connection for container is turned off
Storage Mounts
under normal circumstances, by adding the-v parameter, you can bind a directory on host to container and run container to read and write it .
650) this.width=650; "src=" http://img.blog.csdn.net/20160202180100991 "width=" 803 "height=" 432 "style=" Border:none; " />
Inter-container communication
Through the link parameter, the container port information is exposed to another container, to achieve the communication
650) this.width=650; "src=" http://img.blog.csdn.net/20160202180143288 "width=" 803 "height=" 438 "style=" border:none; " />
This article is from the "Mr_computer" blog, make sure to keep this source http://caochun.blog.51cto.com/4497308/1750763
docker-gis+ "Technology and industry solutions