Fork me on GitHub
#docker
<
2018-01-13
>
davidneu15:01:41

Is anyone doing development using inf-clojure and lein to connect to a socket repl running in a Docker container? I can connect to the repl while inside the container, but when I try to connect from the host I get

telnet 0.0.0.0 5555
Trying 0.0.0.0...
Connected to 0.0.0.0.
Escape character is '^]'.
Connection closed by foreign host.

ghadi19:01:31

@davidneu have you set :address "0.0.0.0" as a parameter to the socket repl?

ghadi19:01:43

-Dclojure.server.repl='{:port 5555 :accept clojure.core.server/repl :address "0.0.0.0"}'

davidneu19:01:09

@ghadi Thanks for the reply! I had actually tried setting :host in the jvm-opts in project.clj. I'm going to try your suggestion now.

ghadi19:01:49

how are you launching the repl?

davidneu19:01:17

I've tried a bunch of different options. I was about to try launching from the command option in my docker-compose.yml.

ghadi19:01:48

are you using lein to launch the repl? @davidneu

davidneu19:01:08

Yes. Is that what you suggest?

ghadi19:01:47

can you paste or DM the entrypoint from docker-compose.yml and the relevant parts of project.clj?

ghadi19:01:19

For a plain socket repl, you'd set that system property above in jvm-opts, and run lein run -m clojure.main (or lein repl which will give you a second repl using nREPL that you don't care about). In docker-compose, you'll want to have a ports: entry mapping "5555:5555"

davidneu19:01:33

Hmmmm, I must be close. That's what I've been trying to do. I'm go through it carefully now that you've confirmed I'm heading in the right direction, and can paste the files if need be.

davidneu19:01:24

@ghadi That worked - thank you! I really appreciate it. It looks like the problem was using setting :host "0.0.0.0" rather than :address "0.0.0.0". I recall looking at the source for clojure.core.server/start-server, so I don't know why I thought it was :host. Thanks again.