I’m trying to run an nrepl via lein in a docker container and jack into it from my local. I’m having trouble actually exposing the port. The port is opened according to docker compose. Is there some other flag I need to invoke? I have tried setting the :host to both local host and 0.0.0.0 via lein in the container.
How does the compose look like? And what does docker ps show?
Docker compose:
clojure-app:
environment:
- GITHUB_ACTOR
- GITHUB_TOKEN
- DATABASE_URL=jdbc:
build:
context: .
dockerfile: Dockerfile
args:
GITHUB_ACTOR: $GITHUB_ACTOR
GITHUB_TOKEN: $GITHUB_TOKEN
volumes:
- .:/opt/treasuryprime/core
working_dir: /opt/treasuryprime/core
command: 'lein with-profile dev repl :headless :host 0.0.0.0 :port 40000'
ports:
- 40000:40000
depends_on:
- db
Docker ps:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
65e888da4ad6 core-clojure-app "lein with-profile d…" About an hour ago Up About an hour core-clojure-app-run-3cdebf92301e
33af2b0dea6c postgres:15 "docker-entrypoint.s…" 21 hours ago Up 21 hours 0.0.0.0:5432->5432/tcp, [::]:5432->5432/tcp core-db-1
Fixed the formatting.
That does not show any mapped ports for the clojure app. So the bug is in the compose file I think
Yeah, sorry, I forgot to answer. The created Clojure container is missing ports indeed
IIRC yaml have some crazy number format support, so I would quote those numbers
I would try:
- "127.0.0.1:40000:40000"
as per https://stackoverflow.com/questions/35429837/docker-compose-port-mapping#46220742
Yeah, there it is: yaml 1.1 supports sexagesimal (base 60) number literals: https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell#sexagesimal-numbers What a feature.
That did the trick for opening the port, thank you! The repl is still hiccuping and dropping connections, but I am able to attempt to connect and will dig into that. Appreciate the help!
the trick for actually receiving non-local nrepl connections was to specify the port on the lein invocation.