Weave creates a virtual network that connects Docker containers deployed across multiple hosts.
Applications use the network just as if the containers were all plugged into the same network switch, with no need to configure port mappings, links, etc. Services provided by application containers on the weave network can be made accessible to the outside world, regardless of where those containers are running. Similarly, existing internal systems can be exposed to application containers irrespective of their location.
Weave can traverse firewalls and operate in partially connected networks. Traffic can be encrypted, allowing hosts to be connected across an untrusted network.
With weave you can easily construct applications consisting of multiple containers, running anywhere.
Weave works alongside Docker's existing (single host) networking capabilities, so these can continue to be used by containers.
weave简单使用
sudo wget -O /usr/local/bin/weave https://raw.githubusercontent.com/zettio/weave/master/weave
sudo chmod a+x /usr/local/bin/weave
启动weave路由器,这个路由器其实也是在docker中启动的:
[root@h-46mow360 ~]# weave launch
Unable to find image 'zettio/weave' locally
3b3a3db2c186fccb5203dcc269b3febbbbf126591a7ebd8117a8a5250683749f
[root@h-46mow360 ~]# brctl show
bridge name bridge id STP enabled interfaces
docker0 8000.56847afe9799 no veth801050a
weave 8000.7afc2a03325e no vethwepl2146
[root@h-46mow360 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b3a3db2c186 zettio/weave:git-a34e214201cb "/home/weave/weaver About a minute ago Up About a minute 0.0.0.0:6783->6783/tcp, 0.0.0.0:6783->6783/udp weave
在两台物理机上分别启动一个容器:
c1=$(weave run 10.0.3.3/24 -t -i -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /tmp/$(mktemp -d):/run systemd:systemd /usr/lib/systemd/systemd)
c2=$(weave run 10.0.3.5/24 -t -i -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /tmp/$(mktemp -d):/run systemd:systemd /usr/lib/systemd/systemd)
这个时候,两个容器之间是不通的,需要在两台weave的路由器之间建立连接:(
if there is a firewall between $HOST1 and $HOST2, you must open port 6783 for TCP and UDP)
weave connect 10.33.0.9
这样,两台容器之间通了:
# nsenter --mount --uts --ipc --net --pid --target $(docker inspect --format "{{.State.Pid}}" "$c2")
-bash-4.2# ping -c 3 10.0.3.3
PING 10.0.3.3 (10.0.3.3) 56(84) bytes of data.
64 bytes from 10.0.3.3: icmp_seq=1 ttl=64 time=2.34 ms
64 bytes from 10.0.3.3: icmp_seq=2 ttl=64 time=1.52 ms
64 bytes from 10.0.3.3: icmp_seq=3 ttl=64 time=1.13 ms
--- 10.0.3.3 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.131/1.667/2.345/0.505 ms
- 应用隔离:不同子网容器之间默认隔离的,即便它们位于同一台物理机上也相互不通;不同物理机之间的容器默认也是隔离的
- 物理机之间容器互通:weave connect $OTHER_HOST
- 动态添加网络:对于不是通过weave启动的容器,可以通过weave attach 10.0.1.1/24 $id来添加网络(detach删除网络)
- 安全性:可以通过weave launch -password wEaVe设置一个密码用于weave peers之间加密通信
- 与宿主机网络通信:weave expose 10.0.1.102/24,这个IP会配在weave网桥上
- 查看weave路由状态:weave ps
- 通过NAT实现外网访问docker容器
Weave creates a network bridge on the host. Each container is connected to that bridge via a veth pair, the container side of which is given the IP address & netmask supplied in ‘weave run’. Also connected to the bridge is the weave router container.
A weave router captures Ethernet packets from its bridge-connected interface in promiscuous mode, using ‘pcap’. This typically excludes traffic between local containers, and between the host and local containers, all of which is routed straight over the bridge by the kernel. Captured packets are forwarded over UDP to weave router peers running on other hosts. On receipt of such a packet, a router injects the packet on its bridge interface using ‘pcap’ and/or forwards the packet to peers.
Weave routers learn which peer host a particular MAC address resides on. They combine this knowledge with topology information in order to make routing decisions and thus avoid forwarding every packet to every peer. The topology information captures which peers are connected to which other peers; weave can route packets in partially connected networks with changing topology.
Weave routers establish TCP connections to each other, over which they perform a protocol handshake and subsequently exchange topology information. These connections are encrypted if so configured. Peers also establish UDP “connections”, possibly encrypted, for the aforementioned packet forwarding. These “connections” are duplex and can traverse firewalls.
After=docker.service
ExecStartPre=/usr/local/bin/weave launch
ExecStart=/usr/bin/docker logs -f weave
SuccessExitStatus=2
ExecStop=/usr/local/bin/weave stop
WantedBy=multi-user.target
相关推荐
Weave 创建一个虚拟网络并连接到部署在多个主机上的 Docker 容器。应用程序使用该网络就好像它们是插在同一个网络交换机上,无需任何配置和端口映射。...Weave 使用 Docker 单机已有的网络功能。 标签:Weave
今天,我们将深入探讨主流 Docker 网络的实现原理,包括 Docker 原生的 Overlay 网络、Weave 网络和 Flannel 网络。 一、容器网络简介 容器网络是 Docker 环境中容器之间的通信网络。它是容器化应用程序的关键组件...
Docker是一种流行的容器化平台,它...通过上述的描述,可以看出Weave作为Docker的跨主机网络解决方案,提供了一个既安全又灵活的网络环境,使得开发者在构建分布式应用时能够更加容易地管理跨多个主机的容器通信问题。
Docker网络是Docker容器之间通信的关键组成...理解并熟练使用这些Docker网络命令对于管理和优化Docker环境至关重要,尤其是在多主机部署和微服务架构中。通过灵活地配置网络,可以确保容器服务的高效、安全和可扩展性。
weave docker镜像
在Docker的世界里,网络是实现容器间通信的关键。Flannel是CoreOS开发的一个轻量级网络解决方案,专为Kubernetes、Docker Swarm等容器编排系统设计,它旨在为跨主机的容器提供一个扁平化的网络环境。本文将深入探讨...
Docker网络增强项目是针对Docker原生网络功能的局限性而发展的一系列解决方案,旨在提供更强大、更灵活的网络管理能力,以满足安全性和特殊功能需求。以下是一些主要的Docker网络增强项目介绍: 1. **Libnetwork**...
Weave是另一种与Docker Overlay类似的网络解决方案,它简化了网络配置,提供了自动发现和自动连接的功能,使得容器网络的管理更为简便。 四、Flannel Flannel是CoreOS开发的轻量级网络解决方案,旨在为Kubernetes...
Docker支持第三方网络驱动程序,如Weave、Flannel、Calico等,这些插件提供更高级的网络特性,如端到端加密、网络策略和路由控制,增强了网络的灵活性和安全性。 6. **网络命名空间和网络栈** Docker容器的网络...
因此,有许多项目如Flannel、Weave、Calico等致力于增强Docker的网络功能,提供更高级的网络策略和隔离。 总的来说,Docker的网络机制通过Linux内核的特性实现了容器间的网络隔离和通信,同时提供了链接、端口暴露...
Docker支持网络驱动插件扩展,如Calico、Weave Net和Flannel等,它们提供了更高级的网络特性,如网络策略控制、IP地址管理、路由和安全性等。这些插件可以增强Docker网络的灵活性和安全性。 六、网络安全 Docker...
为了应对这些挑战,社区发展出了一系列Docker网络优化方案,如Flannel、Weave、Calico等,它们提供更高级别的网络服务,如网络策略、负载均衡和跨主机容器通信。这些项目丰富了Docker的网络生态,使得用户可以根据...
6. **安装网络插件**:k8s 需要网络插件才能使容器通信,如 Flannel、Calico 或 Weave Net。 7. **部署应用**:现在可以使用 kubectl 命令部署应用了,如 `kubectl apply -f <your-deployment-file>.yaml`。 以上...
在Docker网络解决方案中,Pipework、Weave和Flannel是三种常见的工具,它们各自具有不同的优势和适用场景。以下是对这三个工具的详细说明: 1. Pipework: Pipework是一个轻量级的解决方案,它主要适用于单机环境...
在Docker平台上使用Flocker和Weave 观看影片 参见 然后回到这里与Vagrant一起尝试! 流浪汉快速入门 您还将需要安装Vagrant 1.7.2和Virtualbox。 然后: $ git clone git@github.com/plugins-demo-2015/demo ...