Fork me on GitHub
#nrepl
<
2020-09-12
>
Jakub Holý (HolyJak)18:09:06

Hello! I am trying to run nrepl inside Docker for a VSCode remote dev container. The Dockerfile ends up with CMD ["clojure", "-A:nrepl", "--bind", "0.0.0.0"] and the port is defined in deps.edn and exposed and I can connect to it with telnet. But when I connect with a nrepl client, I never get to the prompt, it just freezes:

🐟  clj -A:nrepl --connect --host me --port 52162          [*master]
nREPL 0.8.0-alpha5
Clojure 1.10.1
OpenJDK 64-Bit Server VM 11.0.1+13
Interrupt: Control+C
Exit:      Control+D or (exit) or (quit)
What could it mean? How to troubleshoot? In deps.edn I have
:nrepl {:extra-deps {nrepl/nrepl {:mvn/version "0.8.0-alpha5"}}
        :main-opts ["-m" "nrepl.cmdline" "--port" "52162"]}

Jakub Holý (HolyJak)18:09:06

BTW sometimes it works as it should... So I guess it is some kind of a timing issue.

flowthing05:09:12

I don’t know what the issue is, but I also worked on making a Docker image for running an nREPL server a while back, and ended up with this:

FROM clojure:openjdk-16-tools-deps-alpine
ENV NREPL_VERSION 0.8.0
ENTRYPOINT clojure -Sdeps "{:deps {nrepl/nrepl {:mvn/version \"$NREPL_VERSION\"}}}" --main nrepl.cmdline --bind 0.0.0.0 --port 1234
ADD healthcheck.clj .
HEALTHCHECK --interval=5s --timeout=30s --start-period=5s --retries=5 CMD clojure healthcheck.clj
EXPOSE 1234/tcp
Where healthcheck.clj looks like this:
(import '( Socket))
(Socket. "localhost" 1234)
Not that the health check is necessary in your case. Anyway, it seems to work — at least I haven’t encountered the issue you describe. FWIW. 🙂

👀 3