我试图在Docker Swarm中使用NSQ,但没有成功
mhlg/rpi-nsq是为Raspberry Pi ARM7板构建的Docker镜像,如果作为普通Docker容器运行,我可以确认它能够正常工作
在Docker中运行NSQ(OK)
# crete a bridged network
$ docker network create nsq_network
# run lookupd
$ docker run --name nsqlookupd --network nsq_network -p 4160:4160 -p 4161:4161 mhlg/rpi-nsq nsqlookupd
# run nsqd
$ docker run --name nsqd --network nsq_network -p 4150:4150 -p 4151:4151 mhlg/rpi-nsq nsqd --broadcast-address=nsqd --lookupd-tcp-address=nsqlookupd:4160
# run nsqadmin
$ docker run --name nsqadmin --network nsq_network -p 4171:4171 mhlg/rpi-nsq nsqadmin --lookupd-http-address=nsqlookupd:4161
在Docker Swarm模式下运行NSQ(失败)这是我在Swarm管理器中正在做的事情
# crete an overlay network
$ docker network create nsq_network
# run nsqlookupd
$ docker service create --replicas 1 --name nsqlookupd --network nsq_network -p 4160:4160 -p 4161:4161 mhlg/rpi-nsq nsqlookupd
# run nsqd
$ docker service create --replicas 1 --name nsqd --network nsq_network -p 4150:4150 -p 4151:4151 mhlg/rpi-nsq nsqd --lookupd-tcp-address=nsqlookupd:4160 --broadcast-address=nsqd
# run nsqadmin
$ docker service create --replicas 1 --name nsqadmin --network nsq_network -p 4171:4171 mhlg/rpi-nsq nsqadmin --lookupd-http-address=nsqlookupd:4161
如果我连接到nsqd服务,发现它无法连接到nsqlookupd服务。
[nsqd] 2016/12/09 16:51:56.851953 LOOKUPD(nsqlookupd:4160): sending heartbeat
[nsqd] 2016/12/09 16:51:56.852049 LOOKUP connecting to nsqlookupd:4160
[nsqd] 2016/12/09 16:51:57.852457 LOOKUPD(nsqlookupd:4160): ERROR PING - dial tcp: i/o timeout
看起来覆盖网络创建了一些问题(组播?),但我无法弄清楚如何在ARM设备上解决它。
我尝试通过ssh进入运行nsqd服务的Docker主机,并从nsqd容器内部执行一些dns命令。
# resolve google.com (OK)
root@3206d1c3cd3d:/# nslookup google.com
Server: 127.0.0.11
Address: 127.0.0.11#53
Non-authoritative answer:
Name: google.com
Address: 216.58.214.78
# resolve nsqd service (OK) - can resolve the container I'm executing the command from
root@e1f6430acd1c:/# nslookup nsqd
Server: 127.0.0.11
Address: 127.0.0.11#53
Non-authoritative answer:
Name: nsqd
Address: 10.0.0.2
# resolve nsqlookupd service (FAIL)
root@e1f6430acd1c:/# nslookup nsqlookupd
;; connection timed out; no servers could be reached