
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Maintained by:
https://github.com/nats-io/nats-docker
Where to get help:
https://dockr.ly/comm-slack, Server Fault, https://unix.stackexchange.com/help/on-topic, or https://stackoverflow.com/help/on-topic
Dockerfile links(See https://github.com/docker-library/faq#whats-the-difference-between-shared-and-simple-tags.)
https://github.com/nats-io/nats-docker/blob/aa0caa57b71c01566a100b47b2ed94de6ef6cf80/2.14.x/alpine3.22/Dockerfile
https://github.com/nats-io/nats-docker/blob/aa0caa57b71c01566a100b47b2ed94de6ef6cf80/2.14.x/scratch/Dockerfile
https://github.com/nats-io/nats-docker/blob/aa0caa57b71c01566a100b47b2ed94de6ef6cf80/2.14.x/windowsservercore-ltsc2022/Dockerfile
https://github.com/nats-io/nats-docker/blob/aa0caa57b71c01566a100b47b2ed94de6ef6cf80/2.14.x/nanoserver-ltsc2022/Dockerfile
https://github.com/nats-io/nats-docker/blob/aa0caa57b71c01566a100b47b2ed94de6ef6cf80/2.12.x/alpine3.22/Dockerfile
https://github.com/nats-io/nats-docker/blob/aa0caa57b71c01566a100b47b2ed94de6ef6cf80/2.12.x/scratch/Dockerfile
https://github.com/nats-io/nats-docker/blob/aa0caa57b71c01566a100b47b2ed94de6ef6cf80/2.12.x/windowsservercore-ltsc2022/Dockerfile
https://github.com/nats-io/nats-docker/blob/aa0caa57b71c01566a100b47b2ed94de6ef6cf80/2.12.x/nanoserver-ltsc2022/Dockerfile
2.14.5, 2.14, 2, latest:
2.14.5-windowsservercore, 2.14-windowsservercore, 2-windowsservercore, windowsservercore:
2.14.5-nanoserver, 2.14-nanoserver, 2-nanoserver, nanoserver:
2.12.15, 2.12:
2.12.15-windowsservercore, 2.12-windowsservercore:
2.12.15-nanoserver, 2.12-nanoserver:
Where to file issues:
https://github.com/nats-io/nats-docker/issues?q=is:issue+is:pr
Supported architectures: (https://github.com/docker-library/official-images#architectures-other-than-amd64)
https://hub.docker.com/r/amd64/nats/, https://hub.docker.com/r/arm32v6/nats/, https://hub.docker.com/r/arm32v7/nats/, https://hub.docker.com/r/arm64v8/nats/, https://hub.docker.com/r/ppc64le/nats/, https://hub.docker.com/r/s390x/nats/, https://hub.docker.com/r/winamd64/nats/
Published image artifact details:
https://github.com/docker-library/repo-info/blob/master/repos/nats (https://github.com/docker-library/repo-info/commits/master/repos/nats)
(image metadata, transfer size, etc)
Image updates:
https://github.com/docker-library/official-images/issues?q=label%3Alibrary%2Fnats
https://github.com/docker-library/official-images/blob/master/library/nats (https://github.com/docker-library/official-images/commits/master/library/nats)
Source of this description:
https://github.com/docker-library/docs/tree/master/nats (https://github.com/docker-library/docs/commits/master/nats)
nats is a high performance server for the NATS Messaging System.
bash# 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. # # To actually publish the ports when running the container, use the Docker port mapping # flag "docker run -p <hostport>:<containerport>" to publish and map one or more ports, # or the -P flag to publish all exposed ports and map them to high-order ports. # # This should not be confused with the NATS Server own -p parameter. # For instance, to run the NATS Server and have it listen on port 4444, # you would have to run like this: # # docker run -p 4444:4444 nats -p 4444 # # Or, if you want to publish the port 4444 as a different port, for example 5555: # # docker run -p 5555:4444 nats -p 4444 # # To enable NATS JetStream, use the -js flag: # # docker run -p 4222:4222 nats -js # # And, to persist JetStream data to a volume you can use the -v and -sd flags. # Keep in mind that -v is a Docker flag, while -js and -sd are NATS Server flags: # # docker run -p 4222:4222 -v nats:/data nats -js -sd /data # # Check "docker run" for more information. $ docker run -d --name nats-main -p 4222:4222 -p 6222:6222 -p 8222:8222 nats [INF] Starting nats-server [INF] Version: 2.9.8 [INF] Git: [60e335a] [INF] Cluster: my_cluster [INF] Name: NB3YN6SPZF6MWTLPGYLRE2AD5VVWSW443RO43YR5GC62I463QPYGOL5C [INF] ID: NB3YN6SPZF6MWTLPGYLRE2AD5VVWSW443RO43YR5GC62I463QPYGOL5C [INF] Using configuration file: /etc/nats/nats-server.conf [INF] Starting http monitor on 0.0.0.0:8222 [INF] Listening for client connections on 0.0.0.0:4222 [INF] Server is ready [INF] Cluster name is my_cluster [INF] Listening for route connections on 0.0.0.0:6222 ... # To run a second server and cluster them together.. # Note that since you are passing arguments, this overrides the CMD section # of the Dockerfile, so you need to pass all arguments, including the # config file. $ docker run -d --name=nats-2 --link nats-main -p 4222:4222 -p 6222:6222 -p 8222:8222 nats -c /etc/nats/nats-server.conf --routes=nats-route://ruser:T0pS3cr3t@nats-main:6222 # If you want to verify the routes are connected, try this instead: $ docker run -d --name=nats-2 --link nats-main -p 4222:4222 -p 6222:6222 -p 8222:8222 nats -c /etc/nats/nats-server.conf --routes=nats-route://ruser:T0pS3cr3t@nats-main:6222 -DV [INF] Starting nats-server [INF] Version: 2.9.8 [INF] Git: [60e335a] [DBG] Go build: go1.19.3 [INF] Cluster: my_cluster [INF] Name: NDFNAUTD4RKS2O7CMKMDMTV3DW5NIKFCQDDMXW2A5YXLUZWWX7RYFCKB [INF] ID: NDFNAUTD4RKS2O7CMKMDMTV3DW5NIKFCQDDMXW2A5YXLUZWWX7RYFCKB [INF] Using configuration file: /etc/nats/nats-server.conf [DBG] Created system account: "$SYS" [INF] Starting http monitor on 0.0.0.0:8222 [INF] Listening for client connections on 0.0.0.0:4222 [DBG] Get non local IPs for "0.0.0.0" [DBG] ip=172.17.0.2 [INF] Server is ready [DBG] maxprocs: Leaving GOMAXPROCS=4: CPU quota undefined [INF] Cluster name is my_cluster [INF] Listening for route connections on 0.0.0.0:6222 [DBG] Trying to connect to route on nats-main:6222 (172.17.0.3:6222) [DBG] 172.17.0.3:6222 - rid:4 - Route connect msg sent [INF] 172.17.0.3:6222 - rid:4 - Route connection created [DBG] 172.17.0.3:6222 - rid:4 - Registering remote route "NDQAU6HVD44TI2X5R2QRYJEIQR3MMHCFTW2BTSXBILBOZHJ4Z7AR7GGR" [DBG] 172.17.0.3:6222 - rid:4 - Sent local subscriptions to route
The server will load the configuration file below. Any command line flags can override these values.
bash# Client port of 4222 on all interfaces port: 4222 # HTTP monitoring port monitor_port: 8222 # This is for clustering multiple servers together. cluster { # It is recommended to set a cluster name name: "my_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: 2 } # 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 nats-server docker image to create one to an existing server. routes = [] }
bashServer Options: -a, --addr, --net <host> Bind to host address (default: 0.0.0.0) -p, --port <port> Use port for clients (default: 4222) -n, --name --server_name <server_name> Server name (default: auto) -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 -t Test configuration and exit -sl,--signal <signal>[=<pid>] Send signal to nats-server process (stop, quit, reopen, reload) pid> can be either a PID (e.g. 1) or the path to a PID file (e.g. /var/run/nats-server.pid) --client_advertise <string> Client URL to advertise to other servers --ports_file_dir <dir> Creates a ports file in the specified directory (<executable_name>_<pid>.ports). Logging Options: -l, --log <file> File to redirect log output -T, --logtime Timestamp log entries (default: true) -s, --syslog Log to syslog or windows event log -r, --remote_syslog <addr> Syslog server addr (udp://localhost:514) -D, --debug Enable debugging output -V, --trace Trace the raw protocol -VV Verbose trace (traces system account as well) -DV Debug and trace -DVV Debug and verbose trace (traces system account as well) --log_size_limit <limit> Logfile size limit (default: auto) --max_traced_msg_len <len> Maximum printable length for traced messages (default: unlimited) JetStream Options: -js, --jetstream Enable JetStream functionality -sd, --store_dir <dir> Set the storage directory 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 --cluster_name <string> Cluster Name, if not set one will be dynamically generated --no_advertise <bool> Do not advertise known cluster information to clients --cluster_advertise <string> Cluster URL to advertise to other servers --connect_retries <number> For implicit routes, number of connect retries --cluster_listen <url> Cluster url from which members can solicit routes Profiling Options: --profile <port> Profiling HTTP port Common Options: -h, --help Show this message -v, --version Show version --help_tls TLS help
The nats images come in many flavors, each designed for a specific use case.
nats:<version>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.
nats:<version>-alpineThis image is based on the popular [***] available in https://hub.docker.com/_/alpine. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.
This variant is useful when final image size being as small as possible is your primary concern. The main caveat to note is that it does use https://musl.libc.org instead of https://www.etalabs.net/compare_libcs.html, so software will often run into issues depending on the depth of their libc requirements/assumptions. See this Hacker News comment thread for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.
To minimize image size, it's uncommon for additional related tools (such as git or bash) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the https://hub.docker.com/_/alpine/ for examples of how to install packages if you are unfamiliar).
nats:<version>-windowsservercoreThis image is based on https://hub.docker.com/r/microsoft/windows-servercore. 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 https://github.com/nats-io/gnatsd/blob/master/LICENSE for the software contained in this image.
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
Some additional license information which was able to be auto-detected might be found in https://github.com/docker-library/repo-info/tree/master/repos/nats.
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务
以下是 nats 相关的常用 Docker 镜像,适用于 不同场景 等不同场景: