NATS

Description
URL

Official website

DockerHub image

NATS Go SDK

NATS JS SDK

NATS Python SDK

NKeys repository

NATS CLI tool

Configuration

NKey generation

nats-nkey:
	nk -gen user -pubout

Server

This file should be available on the system running NATS. NATS should be started using the --config or -c flag pointing to the path of this file (eg. nats-server -c /path/to/this.conf

accounts: {
  $SYS: {
    users: [
      # generate using `nk-gen user -pubout`
      {nkey: "..."},
    ]
  }
}

authorization: {
  users: [
    # generate using `nk-gen user -pubout`
    {nkey: "..."},
  ]
}

cluster: {
  name: "example"
}

jetstream: {
  max_memory_store: 2GB
  max_file_store: 8GB
}

Docker

Image

Compose

The following starts NATS using the leanest image base (scratch) and with JetStream enabled:

version: "3.7"
services:
  nats: # access with `nats server info`
    # image reference: https://hub.docker.com/_/nats
    image: library/nats:2.9.20-scratch
    entrypoint:
      - /nats-server
      - -js
      - -c
      - /etc/nats/server.conf
    ports:
      - "4222:4222"
      # # enable as needed
      # - "6222:6222"
      # - "8222:8222"
    network_mode: host
    volumes:
      - ./.data/nats/config/server.conf:/etc/nats/server.conf

Last updated