官术网_书友最值得收藏!

Docker default networks

The following are some of Docker's default networks:

  • Bridge network: In a nonswarm scenario, Docker will use the bridge network driver (called bridge) to allow standalone containers to speak to each other. You can think of the bridge as a link layer device that forwards network traffic between segments. If containers are connected to the same bridge network, they can communicate; if they're not connected, they can't. The bridged network is the default choice unless otherwise specified. In this mode, the container has its own networking namespace and is then bridged via virtual interfaces to the host (or node, in the case of K8s) network. In the bridged network, two containers can use the same IP range because they are completely isolated. Therefore, service communication requires some additional port mapping through the host side of network interfaces.
  • Host based: Docker also offers host-based networking for standalone containers, which creates a virtual bridge called docker0 that allocates private IP address space for the containers using that bridge. Each container gets a virtual Ethernet (veth) device that you can see in the container as eth0. Performance is greatly benefited since it removes a level of network virtualization; however, you lose the security of having an isolated network namespace. Additionally, port usage must be managed more carefully since all containers share an IP.

There's also a none network, which creates a container with no external interface. Only a loopback device is shown if you inspect the network interfaces.

In all of these scenarios, we are still on a single machine, and outside of  host mode, the container IP space is not available outside that machine. Connecting containers across two machines requires NAT and port mapping for communication.

主站蜘蛛池模板: 南雄市| 班玛县| 富顺县| 丘北县| 沈丘县| 屏南县| 白山市| 栾城县| 尖扎县| 卢湾区| 库尔勒市| 深泽县| 茂名市| 浦城县| 林周县| 肇东市| 洱源县| 鹰潭市| 长顺县| 冀州市| 万安县| 临沭县| 平塘县| 岐山县| 龙口市| 天门市| 丹凤县| 喀什市| 凌源市| 阿鲁科尔沁旗| 那曲县| 全州县| 石阡县| 贵州省| 鹤庆县| 平舆县| 江西省| 嫩江县| 沈阳市| 涟水县| 长治市|