Over a million developers have joined DZone.

How to Network Docker Containers with Weave

DZone 's Guide to

How to Network Docker Containers with Weave

· Cloud Zone ·
Free Resource

Zettio, created by the founders of RabbitMQ, has released Weave--a new networking system for Docker containers. Docker can already connect containers on a single host, but now networked containers can interact even across an unsecured network.

Installing Weave is relatively simple to do on a host.

To run weave on a host, you need to install...

  1. docker. We've tested with versions 0.9.1 through 1.2.0, but other versions should work too.
  2. weave. Install this with

    sudo wget -O /usr/local/bin/weave \
    sudo chmod a+x /usr/local/bin/weave
  3. (recommended) ethtool. On many systems this is installed already; if not then grab it via your favourite package manager. On some systems, weave application container networking may not operate correctly unless ethtool is available.

  4. (optional) conntrack. Install this via your favourite package manager. Without conntrack, the weave network may not re-establish itself fully when individual weave instances are stopped (with weave stop) and restarted quickly (typically within ~3 minutes).

Zettio also provides some good examples of now only how to use Weave, but in what situations you may want to use it. They've also included a list of features for the software, including:
  • Virtual Ethernet Switch — basically amasses your containers in a way that is similar to a giant Ethernet network, and allows deploy of basic networking tools.
  • Application Isolation — a network can host multiple, isolated applications, with each application's containers being able to communicate with each other but not containers of other applications.
  • Security – weave has standard traffic encryption and password protected capabilities.
  • Host Network Integration — Weave application networks can be integrated with a host's network, establishing connectivity between the host and application containers anywhere.
  • Service Export — services running in containers on a weave network can be made accessible to the outside world from any weave host.
  • Service Import — applications running in containers on a weave network can be given access to services which are only reachable from certain weave hosts.
  • Multi-Cloud Networking — Weave can network containers hosted in different cloud providers / data centres.
  • Multi-Hop Routing — a network of containers between two hosts can be established even when there is only partial connectivity between the hosts. 
  • Dynamic Topologies — to add a host to an existing weave network, one simply launches weave on the host, supplying the address of at least one existing host.
  • Container Mobility — containers can be moved between hosts without requiring any reconfiguration or, in many cases, restarts of other containers.
  • Fault Tolerance — Weave peers continually exchange topology information, and monitor and (re)establish network connections to other peers. So if hosts or networks fail, weave can "route around" the problem.
The features are an impressive bonus, but the guts of this release is really their explanation of how Weave accomplishes this networking. They explain how the Docker networking works in better words than I could, and they have a pretty extensive set of Weave documentation on GitHub. Definitely take a look and see how it works.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}