Docker Swarm覆盖网络通信

时间:2016-12-09 20:30:47

标签: networking docker overlay swarm

我试图设置一个Docker Swarm,其中容器使用Overlay Network进行通信,但我可以使其工作

我使用包含Docker Engine 1.12.1的HypriotOS 1.0.0 Linux发行版使用4个Raspberry Pi 3板模拟基础架构

Swarm初始化ssh到manger节点

之后
# 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

我无法ping服务我做错了什么?

我已经启动了这个问题,因为我试图在docker swarm上运行NSQ,我认为我的问题与覆盖网络有关!

这是最初的问题 NSQ Docker Swarm

2 个答案:

答案 0 :(得分:1)

尝试重新创建这样的网络: docker network create -d overlay --attachable ${NAme}

答案 1 :(得分:0)

不需要网络,一旦管理员初始化“ docker swarm init”,并且任何时候节点加入网络,docker都会创建少量覆盖网络。

网络是(入口和docker_gwbridge)

您可以在此处(vagrant-docker-cluster)使用无用的VM检查模拟设置