Introducing our new CEO Don Johnson - Read More

weaveworks/net-plugin

By weaveworks

Updated about 4 years ago

Plugin
10

1M+

  1. Setup your Docker Swarm cluster:

     host1$ docker swarm init --advertise-addr="$(hostname -i)"
     host2$ docker swarm join --token <token> <host>:<port>
    
  2. Install the Weave Net plugin on all hosts:

     host1$ docker plugin install --grant-all-permissions weaveworks/net-plugin:2.5.2
     host2$ docker plugin install --grant-all-permissions weaveworks/net-plugin:2.5.2
    
  3. On your master, create a Docker Network using the Weave Net plugin as the driver:

     host1$ docker network create --driver=weaveworks/net-plugin:2.5.2 weavenet
    
  4. Configure your Docker Swarm service:

     host1$ docker service create --network=weavenet --replicas=2 --name=foo -p 1234:12345 alpine /bin/sh -c "echo pong | nc -l -p 12345"
    
  5. Hosts host1 and host2 both have a replica of the foo container running locally:

     host1$ docker ps --filter name=foo* --format "table {{.ID}}\t{{.Names}}"
     CONTAINER ID        NAMES
     3aa568131962        foo.1
     host1$ echo ping | nc $(hostname -i) 1234
     pong
     
     host2$ docker ps --filter name=foo* --format "table {{.ID}}\t{{.Names}}"
     CONTAINER ID        NAMES
     8adc8dd527c4        foo.2
     host2$ echo ping | nc $(hostname -i) 1234
     pong
    
  6. Containers foo.1 and foo.2 are able to communicate over the weavenet network:

     host1$ docker exec -ti foo.1 /bin/sh
     / # ping -c1 -w1 foo.2
     PING foo.2 (10.0.0.4): 56 data bytes
     64 bytes from 10.0.0.4: seq=0 ttl=64 time=1.250 ms
     
     --- foo.2 ping statistics ---
     1 packets transmitted, 1 packets received, 0% packet loss
     round-trip min/avg/max = 1.250/1.250/1.250 ms
     
     / # echo ping | nc foo.2:12345
     pong
     
     host2$ docker exec -ti foo.2 /bin/sh
     / # ping -c1 -w1 foo.1
     PING foo.1 (10.0.0.3): 56 data bytes
     64 bytes from 10.0.0.3: seq=0 ttl=64 time=1.834 ms
     
     --- foo.1 ping statistics ---
     1 packets transmitted, 1 packets received, 0% packet loss
     round-trip min/avg/max = 1.834/1.834/1.834 ms
     
     / # echo ping | nc foo.1:12345
     pong
    

Docker Pull Command

docker plugin install weaveworks/net-plugin