在Docker中运行NSQ

时间:2015-05-29 09:52:51

标签: docker nsq

我正在尝试使用docker-compose启动NSQ。

nsqlookupd:
  image: nsqio/nsqlookupd
  ports:
    - "4160:4160"
    - "4161:4161"

nsqd:
  image: nsqio/nsqd
  ports:
    - "4150"
    - "4151"
  links:
    - nsqlookupd:nsqlookupd
  command: -lookupd-tcp-address=nsqlookupd:4160

nsqadmin:
  image: nsqio/nsqadmin
  ports:
    - "4171:4171"
  links:
    - nsqlookupd:nsqlookupd
  command: -lookupd-http-address=nsqlookupd:4161

容器运行正常,我甚至可以通过Web浏览器访问管理面板,但是无法连接到nsqd:

~/D/t/nsq % boot2docker ip
192.168.59.103
~/D/t/nsq % curl -d 'hello world 1' 'http://192.168.59.103:4150/put?topic=test'
curl: (7) Failed to connect to 192.168.59.103 port 4150: Connection refused
~/D/t/nsq %

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

两件事:
1)撰写文件中的nsqd条目应正确公开端口:
ports: - "4150:4150" - "4151:4151"

2)HTTP接口的端口是4151,所以试试
curl -d 'hello world 1' 'http://192.168.59.103:4151/put?topic=test'