Official Repository

Last pushed: a month ago
Short Description
NATS is an open-source, high-performance, cloud native messaging system.
Full Description

Supported tags and respective Dockerfile links

For more information about this image and its history, please see the relevant manifest file (library/nats). This image is updated via pull requests to the docker-library/official-images GitHub repo.

For detailed information about the virtual/transfer sizes and individual layers of each of the above supported tags, please see the repos/nats/ file in the docker-library/repo-info GitHub repo.

NATS: A high-performance cloud native messaging system.

nats is a high performance server for the NATS Messaging System.

Example usage

# Run a NATS server
# Each server exposes multiple ports
# 4222 is for clients.
# 8222 is an HTTP management port for information reporting.
# 6222 is a routing port for clustering.
# use -p or -P as needed.

$ docker run -d --name nats-main nats
[INF] Starting nats-server version 0.9.6
[INF] Starting http monitor on
[INF] Listening for client connections on
[INF] Server is ready
[INF] Listening for route connections on


# To run a second server and cluster them together..
$ docker run -d --name=nats-2 --link nats-main nats --routes=nats-route://ruser:T0pS3cr3t@nats-main:6222

# If you want to verify the routes are connected, try
$ docker run -d --name=nats-2 --link nats-main nats --routes=nats-route://ruser:T0pS3cr3t@nats-main:6222 -DV
[INF] Starting nats-server version 0.9.6
[DBG] Go build version go1.6.3
[INF] Starting http monitor on
[INF] Listening for client connections on
[DBG] Server id is HQLO4vvXi434nlqWjbTbec
[INF] Server is ready
[INF] Listening for route connections on
[DBG] Trying to connect to route on nats-main:6222
[DBG] - rid:1 - Route connection created
[DBG] - rid:1 - Route connect msg sent
[DBG] - rid:1 - Registering remote route "PRJPXBdDnqK5ATfyQ7Jjlv"
[DBG] - rid:1 - Route sent local subscriptions

The server will load the configuration file below. Any command line flags can override these values.

Default Configuration File

# Client port of 4222 on all interfaces
port: 4222

# HTTP monitoring port
monitor_port: 8222

# This is for clustering multiple servers together.
cluster {

  # Route connections to be received on any interface on port 6222
  port: 6222

  # Routes are protected, so need to use them with --routes flag
  # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222
  authorization {
    user: ruser
    password: T0pS3cr3t
    timeout: 0.75

  # Routes are actively solicited and connected to from this server.
  # This Docker image has none by default, but you can pass a
  # flag to the gnatsd docker image to create one to an existing server.
  routes = []

Commandline Options

Server Options:
    -a, --addr <host>                Bind to host address (default:
    -p, --port <port>                Use port for clients (default: 4222)
    -P, --pid <file>                 File to store PID
    -m, --http_port <port>           Use port for http monitoring
    -ms,--https_port <port>          Use port for https monitoring
    -c, --config <file>              Configuration file

Logging Options:
    -l, --log <file>                 File to redirect log output
    -T, --logtime                    Timestamp log entries (default: true)
    -s, --syslog                     Enable syslog as log method
    -r, --remote_syslog <addr>       Syslog server addr (udp://localhost:514)
    -D, --debug                      Enable debugging output
    -V, --trace                      Trace the raw protocol
    -DV                              Debug and trace

Authorization Options:
        --user <user>                User required for connections
        --pass <password>            Password required for connections
        --auth <token>               Authorization token required for connections

TLS Options:
        --tls                        Enable TLS, do not verify clients (default: false)
        --tlscert <file>             Server certificate file
        --tlskey <file>              Private key for server certificate
        --tlsverify                  Enable TLS, verify client certificates
        --tlscacert <file>           Client certificate CA for verification

Cluster Options:
        --routes <rurl-1, rurl-2>    Routes to solicit and connect
        --cluster <cluster-url>      Cluster URL for solicited routes
        --no_advertise <bool>        Advertise known cluster IPs to clients

Common Options:
    -h, --help                       Show this message
    -v, --version                    Show version
        --help_tls                   TLS help

Image Variants

The nats images come in many flavors, each designed for a specific use case.


This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.


This image is based on Windows Server Core (microsoft/windowsservercore). As such, it only works in places which that image does, such as Windows 10 Professional/Enterprise (Anniversary Edition) or Windows Server 2016.

For information about how to get Docker running on Windows, please see the relevant "Quick Start" guide provided by Microsoft:


View license information for the software contained in this image.

Supported Docker versions

This image is officially supported on Docker version 1.13.1.

Support for older versions (down to 1.6) is provided on a best-effort basis.

Please see the Docker installation documentation for details on how to upgrade your Docker daemon.

User Feedback


If you have any problems with or questions about this image, please contact us through a GitHub issue. If the issue is related to a CVE, please check for a cve-tracker issue on the official-images repository first.

You can also reach many of the official image maintainers via the #docker-library IRC channel on Freenode.


You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.

Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.


Documentation for this image is stored in the nats/ directory of the docker-library/docs GitHub repo. Be sure to familiarize yourself with the repository's file before attempting a pull request.

Docker Pull Command

Comments (4)
3 months ago

I was having the same problem, and it was solved when I added a "--link" to my nats client container.

Btw, you can verify if your application is subscribed to the nats server by opening in a browser the nats monitor (served by default on 8222 of the nats server)

4 months ago

I have one container running mysql, a second container running nats and a third container running lapidus and my nodejs code. The third container is supposed to link to the first and second containers (according to my boss so i cant argue why).
Now, I can connect to mysql using mysql's alias 'db' (that i provided using --link) as host name.
What I can not seem to do is connect to nats server from the third container. This is my lapidus.json file:

"backends": [
"type": "mysql",
"hostname": "db",
"username": "root",
"database": "collectionserverdb",
"password": "password",
"serverId": 1
"plugins": {
"nats": {
"server": "nats://localhost:4222"

I have also tried other values for server like
"nats://" (i got the ip of nats container using inspect)
"nats://natsserver:4222" (the alias natsserver that i provided while linking it to the third container)

I also tried to bind nats container's port 4222 to a free port on my host and tried to connect to nats through localhost but that can only be accessed if i run my code on host but does not work if I run my code in a container (because then, it is in a separate network bridge).

I tried a couple of other things as well that might sound stupid, so, I rather not mention them.

If anyone has any information regarding connecting a container to a container running nats, please do drop a comment and please do not ask me to google because I have been doing that for 3 days before finally coming here. fingerscrossed

8 months ago

Description is outdated, 0.8.1 requires the --cluster parameter to be passed, pass --cluster to get the default previous default behaviour.

a year ago