This guide uses Docker to run NSQ with its core components: nsqd, nsqlookupd, and nsqadmin.
For Docker installation, see Docker.
Create a directory to store your configuration and compose files.
mkdir -p /opt/nsq
cd /opt/nsq
Define containers for NSQ components using the official image.
Note: NSQ consists of multiple components:
services:
nsqlookupd:
image: nsqio/nsq:v1.3.0
container_name: nsqlookupd
command: /nsqlookupd
ports:
- "4160:4160" # TCP for nsqd registration
- "4161:4161" # HTTP for nsqadmin and clients
restart: unless-stopped
nsqd:
image: nsqio/nsq:v1.3.0
container_name: nsqd
command: /nsqd --lookupd-tcp-address=nsqlookupd:4160
ports:
- "4150:4150" # TCP for client connections
- "4151:4151" # HTTP for admin API
depends_on:
- nsqlookupd
restart: unless-stopped
nsqadmin:
image: nsqio/nsq:v1.3.0
container_name: nsqadmin
command: /nsqadmin --lookupd-http-address=nsqlookupd:4161
ports:
- "4171:4171" # Web UI
depends_on:
- nsqlookupd
restart: unless-stopped
Start the containers in the background.
docker compose up -d
Check container status:
docker compose ps
Access the web UI at http://localhost:4171.
Test publishing a message:
# Publish a message via HTTP
curl -d 'Hello NSQ!' 'http://localhost:4151/pub?topic=test'
# Check topic stats
curl 'http://localhost:4151/stats?format=json' | jq
nsqio/nsq is the official NSQ Docker imageAny questions?
Feel free to contact us. Find all contact information on our contact page.