【问题标题】:Running NSQ in Docker在 Docker 中运行 NSQ
【发布时间】:2015-08-12 03:20:24
【问题描述】:

我正在尝试使用 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

容器运行良好,我什至可以通过网络浏览器访问管理面板,但无法连接到 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 %

有什么想法吗?

【问题讨论】:

    标签: docker nsq


    【解决方案1】:

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

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

    【讨论】:

    • 您的意思是在第 (2) 点将端口更改为 4151 吗?即:curl -d 'hello world 1' 'http://192.168.59.103:4151/put?topic=test'
    • 如果我通过“4150:4150”暴露端口,我仍然会得到error connecting to nsqd - dial tcp 192.168.59.103:4150: connection refused
    • 我认为@21Zoo 建议您尝试连接到端口 4151,而不是 4150。
    • 啊,是的,让我编辑一下,curl 应该尝试连接到端口 4151。
    • 谢谢,它现在可以工作了 :) 我的 macbook 蓝屏了,所以我忘了在这里回复。
    猜你喜欢
    • 2017-04-25
    • 2015-10-25
    • 1970-01-01
    • 2020-04-22
    • 1970-01-01
    • 2021-10-03
    • 2021-07-13
    • 2018-05-20
    • 2021-07-29
    相关资源
    最近更新 更多