Search code examples
dockernsq

Running NSQ in Docker


I am trying to spin up NSQ using docker-compose.

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

The containers run fine, I can even access the admin panel via web browser, but connecting to nsqd is not possible:

~/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 %

Any ideas?


Solution

  • Two things:
    1) the nsqd entry in your compose file should properly expose the ports:
    ports: - "4150:4150" - "4151:4151"

    2) the port for the HTTP interface is 4151 so try
    curl -d 'hello world 1' 'http://192.168.59.103:4151/put?topic=test'