Gavello
Gavello

Reputation: 1491

Docker Swarm Overlay Network Communication

I'm trying to setup a Docker Swarm where containers comunicate using Overlay Network but I can make it work

I'm simulating the infrastructure using 4 Raspberry Pi 3 Boards using HypriotOS 1.0.0 Linux distribution which include Docker Engine 1.12.1

After Swarm initialization ssh into manger node

# create one overlay network
$ docker network create --driver overlay swarm_network

# create first service (foo)
$ docker service create --replicas 1 --name foo --network swarm_network resin/rpi-raspbian tail -F -n0 /etc/hosts

# create second service (bar)
$ docker service create --replicas 1 --name bar --network swarm_network resin/rpi-raspbian tail -F -n0 /etc/hosts

# list services
$ docker service ls
ID            NAME  REPLICAS  IMAGE               COMMAND
aqhcndcdoaf4  bar   1/1       resin/rpi-raspbian  tail -F -n0 /etc/hosts
cylg7ws3egx7  foo   1/1       resin/rpi-raspbian  tail -F -n0 /etc/hosts

# find docker host running foo service
$ docker service ps foo
ID                         NAME   IMAGE               NODE     DESIRED  STATE  CURRENT STATE              ERROR
ed6z74ncz1zf0dqc7wph5huvk  foo.1  resin/rpi-raspbian  swarm-2  Running  Running about an hour ago

ssh into swarm-2 node

$docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS               NAMES
78b0e421efcd        resin/rpi-raspbian:latest   "/usr/bin/entry.sh ta"   48 seconds ago      Up 45 seconds                           foo.1.ed6z74ncz1zf0dqc7wph5huvk

# exec into the running container 
$ docker exec -it foo.1.ed6z74ncz1zf0dqc7wph5huvk /bin/bash

# try dns resolution (OK)
root@78b0e421efcd:/# nslookup bar                                                                   
Server:     127.0.0.11
Address:    127.0.0.11#53

Non-authoritative answer:
Name:   bar
Address: 10.0.1.4

# ping bar service (FAIL) 
root@314b0ef6c82c:/# ping -c 1 bar
PING bar (10.0.1.4) 56(84) bytes of data.
From 314b0ef6c82c (10.0.1.3) icmp_seq=1 Destination Host Unreachable

--- bar ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

I'm unable to ping my services what I'm doing wrong?

I've started this question because I'm trying to run NSQ on docker swarm and I thought my issues were related to the overlay network!

Here is the initial question NSQ Docker Swarm

Upvotes: 5

Views: 1014

Answers (2)

Wandawi Najeeb R
Wandawi Najeeb R

Reputation: 692

No network is needed, docker creates few overlay networks once a manager is initialised ‘docker swarm init’ and anytime a node joins the network.

The networks are (ingress & docker_gwbridge)

You can check a simulated setup using vagrant VMs here (vagrant-docker-cluster)

Upvotes: -1

smaiakov
smaiakov

Reputation: 480

Try to recreate network like this : docker network create -d overlay --attachable ${NAme}

Upvotes: 2

Related Questions