calva

kiemdoder 2025-08-28T08:12:16.178419Z

I need to develop my app while it is running in a docker container. I've tried a few things that I can elaborate on but before I do I would like to ask if there is a recommended way to do repl driven development with the project running in a docker container.

pez 2025-08-28T11:31:25.736839Z

I’m not able to answer with any tips here right now. But tonight I can share what little I know about it. Hopefully others will have beaten me to it!

kiemdoder 2025-08-28T11:32:25.849219Z

I'm looking forward to the Joyride presentation!

1
kiemdoder 2025-08-28T11:40:11.847899Z

I tried the following.. deps.edn:

{
  ...
  aliases {
    :repl/headless {:extra-deps {nrepl/nrepl {:mvn/version "1.3.1"}
                               cider/cider-nrepl {:mvn/version "0.40.0"}}
                  :main-opts  ["--main" "nrepl.cmdline"
                               "--middleware" "[cider.nrepl/cider-middleware]"
                               "--port" "50000"]}
  }
}
Dockerfile:
FROM clojure:tools-deps-trixie-slim
WORKDIR /app
COPY src /app/src
COPY deps.edn /app/deps.edn
EXPOSE 50000
ENTRYPOINT ["clj", "-M:repl/headless"]
docker-compose.yml:
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 50000:50000
    volumes:
      - .:/app
Once the container is running I try to connect to the REPL at localhost:50000 from Calva but then I get the following error:
Connecting ...

Reading port file: file:///Users/garfield/dev/clojure/my-app/.nrepl-port ...

Using host:port localhost:50000 ...

Hooking up nREPL sessions ...

nREPL connection failed: Error: read ECONNRESET

Failed connecting.

kiemdoder 2025-08-28T11:41:51.927489Z

From the container output I can see that the REPL server is running:

app-1  | nREPL server started on port 50000 on host localhost - 

seancorfield 2025-08-28T12:33:35.180869Z

You probably need to specify the host as 0.0.0.0 when starting the repl.

kiemdoder 2025-08-28T12:52:10.697689Z

Ah, thank you. I added --bind 0.0.0.0 to deps.edn and now it works.

{
  ...
  aliases {
    :repl/headless {:extra-deps {nrepl/nrepl {:mvn/version "1.3.1"}
                               cider/cider-nrepl {:mvn/version "0.40.0"}}
                  :main-opts  ["--main" "nrepl.cmdline"
                               "--middleware" "[cider.nrepl/cider-middleware]"
                               "--bind" "0.0.0.0"
                               "--port" "50000"]}
  }
}

2025-08-28T17:48:06.905729Z

VsCode and therefore Calva support "remote development" in a container. So you can "connect" to the container and then all works as expected. This expects the code being in the container as well, not sure this fits your setup.

kiemdoder 2025-08-29T11:25:48.503989Z

Thank you Carsten. I will try that option out as well.