# Self-host NATS

> A lightweight messaging server for pub/sub, request/reply and durable streams, with JetStream persistence enabled.

- Page: https://levelrail.com/templates/nats/
- JSON: https://levelrail.com/templates/nats.json
- Category: Infrastructure
- Licence: Apache-2.0 (Permissive license)
- Source: https://github.com/nats-io/nats-server
- Upstream docs: https://docs.nats.io/

## Requirements
- Memory: about 128 MiB
- amd64: published, arm64: tested
- Needs configuration before start: no
- Pinned image tag: 2.10-alpine

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| nats | nats | 2.10-alpine | 4222, 8222 | nats_data -> /data |

## Deploy

### CLI

```bash
levelrail-cli templates deploy nats --name my-nats
```

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" \
  https://levelrail.example.com/api/v1/service-templates/nats/deploy
```

Create a token in the dashboard first. This one-click route deploys it as a trial app you can keep or remove.

## Questions

### Can I deploy NATS on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list we compared does not have an entry with the same id for NATS, so on Dokploy you would use a Docker Compose application with the file from this page. Dokku deploys container images with its own commands, so the pinned image nats:2.10-alpine is what you deploy there.

Self-host NATS, NATS docker compose file, deploy NATS on a VPS: this page lists the pinned image, ports, volumes and the commands for each.
