docker

davidneu 2018-01-13T15:40:41.000056Z

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.

ghadi 2018-01-13T19:00:31.000022Z

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

ghadi 2018-01-13T19:02:43.000054Z

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

davidneu 2018-01-13T19:08:09.000098Z

@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.

ghadi 2018-01-13T19:08:49.000024Z

how are you launching the repl?

davidneu 2018-01-13T19:15:17.000040Z

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

ghadi 2018-01-13T19:18:48.000074Z

are you using lein to launch the repl? @davidneu

davidneu 2018-01-13T19:23:08.000126Z

Yes. Is that what you suggest?

ghadi 2018-01-13T19:23:47.000065Z

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

ghadi 2018-01-13T19:26:19.000081Z

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"

davidneu 2018-01-13T19:29:33.000076Z

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.

davidneu 2018-01-13T19:57:24.000005Z

@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.