5

我正在尝试设置一个 Docker Swarm,其中容器使用覆盖网络进行通信,但我可以让它工作

我正在使用 4 个 Raspberry Pi 3 板使用 HypriotOS 1.0.0 Linux 发行版(包括 Docker Engine 1.12.1)模拟基础设施

Swarm 初始化后 ssh 进入管理器节点

# 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 进入 swarm-2 节点

$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

4

2 回答 2

2

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

于 2017-05-13T04:44:35.370 回答
-1

不需要网络,一旦管理器被初始化为“docker swarm init”并且任何时候节点加入网络,docker 就会创建很少的覆盖网络。

网络是(入口和 docker_gwbridge)

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

于 2019-06-19T17:14:36.390 回答