码迷,mamicode.com
首页 > Web开发 > 详细

Docker network

时间:2018-05-26 10:45:29      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:targe   start   sig   ext   level   tutorial   network   XA   interface   

1 Hostnetwork 

NETWORK: HOST

With the network set to host a container will share the host’s network stack and all interfaces from the host will be available to the container. The container’s hostname will match the hostname on the host system

Compared to the default bridge mode, the host mode gives significantly better networking performance since it uses the host’s native networking stack whereas the bridge has to go through one level of virtualization through the docker daemon. It is recommended to run containers in this mode when their networking performance is critical, for example, a production Load Balancer or a High Performance Web Server.

NETWORK: BRIDGE

Isolated network within the host. With the network set to bridge a container will use docker’s default networking setup. A bridge is setup on the host, commonly named docker0, and a pair of veth interfaces will be created for the container. One side of the vethpair will remain on the host attached to the bridge while the other side of the pair will be placed inside the container’s namespaces in addition to the loopback interface. An IP address will be allocated for containers on the bridge’s network and traffic will be routed though this bridge to the container. Containers can talk to each other, and to talk to outside of the host, need to expose the port by docker run -p <exposed port of host>:<port of container> <container_name>

 

NETWORK: Overlay

overlay netwrok is designed for the comms between two containers on different host. 

To create overlay network 

docker network create -d overlay my-overlay

Start a service using the overlay network and publishing port 80 to port 8080 on the Docker host.

$ docker service create   --name my-nginx   --network my-overlay   --replicas 1   --publish published=8080,target=80   nginx:latest

for muti host overlay network

https://docs.docker.com/network/network-tutorial-overlay/#walk-through

Docker network

标签:targe   start   sig   ext   level   tutorial   network   XA   interface   

原文地址:https://www.cnblogs.com/anyu686/p/9091533.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!