nats-io/nats-docker

can't load nats-server.conf

dtest11 opened this issue · 2 comments

1.use docker hub image

docker run  -v /home/lbq/Desktop/nats-server.conf:/etc/nats/nats-server.conf --name nats -p 4222:4222 -p 6222:6222 -p 8222:8222 nats

  1. nats-server.conf

listen: 0.0.0.0:4222
http: 0.0.0.0:8222
debug:   true
trace:   true
logtime: true
max_connections: 1
max_control_line: 512
max_payload: 65536
write_deadline: "2s"

  1. consumer.go
package main

import (
	"fmt"
	"time"

	"github.com/nats-io/nats.go"
)

func main() {
	nc, err := nats.Connect(nats.DefaultURL)
	if err != nil {
		panic(err)
	}
	defer nc.Close()
	fmt.Println("connect......")
	time.Sleep(5 * time.Minute)
}

we start 2 consumer ,but the nats-server still receive 2 connect ,but we already set max_connections=1

  1. use the github repo(nats-docker) try to build image , load conf success

not sure which of the Dockerfiles here is just nats, but docker history suggests you have to mount the config to /nats-server.conf

[rip@dev1]% docker history nats --no-trunc                                                                                                                                                                                                                                                                                                                                         <17:03:44
IMAGE                                                                     CREATED             CREATED BY                                                                                                           SIZE                COMMENT
sha256:f3903d09e582715d83e8da5706ee14109824854452c0ebf177eb55dfb789e311   4 weeks ago         /bin/sh -c #(nop)  CMD ["--config" "nats-server.conf"]                                                               0B
<missing>                                                                 4 weeks ago         /bin/sh -c #(nop)  ENTRYPOINT ["/nats-server"]                                                                       0B
<missing>                                                                 4 weeks ago         /bin/sh -c #(nop)  EXPOSE 4222 6222 8222                                                                             0B
<missing>                                                                 4 weeks ago         /bin/sh -c #(nop) COPY file:bef66f144841968228eb6875fdca1fb9c094da90455a3e05090bdd09e690e7ea in /nats-server.conf    670B
<missing>                                                                 4 weeks ago         /bin/sh -c #(nop) COPY file:6d5e77e6be5bafda9b9e03a4f397b21f9432694e3c3c3b5cd6e621b4c3ec3018 in /nats-server         10.8MB

@ripienaar right , mount at / is solution ,tks.