Fork me on GitHub
#pedestal
<
2018-12-15
>
yefoakira22:12:07

Hello, just starting with pedestal. I have the hello-world example. When I use from my terminal lein run-dev I get the expected answer. I have added a Dockerfile and a docker-compose.yml running the same command. The jetty server starts inside the container, but I get a connection was reset when navigating to the correct port. I'm using (constantly true) for :allowed-origins. Does anyone know what I am missing?

mtnygard22:12:51

@yefoakira Can you share your Dockerfile and docker-compose.yml here?

yefoakira22:12:30

Sure Dockerfile:

FROM clojure:lein
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY project.clj /usr/src/app
RUN lein deps
EXPOSE 8080

yefoakira22:12:55

docker-compose.yml

version: '3'
services:
  web:
    build: .
    ports:
      - "4001:8080"
    volumes:
      - .:/usr/src/app
    command: lein run-dev

mtnygard22:12:40

I see that your Dockerfile copies the project.clj into the container, but I don't see how your application source gets copied.

yefoakira22:12:55

volumes: on docker-compose links my folder with my source into /usr/src/app

mtnygard22:12:29

What do you see in the logs from docker-compose?

yefoakira22:12:37

last lines are:

web_1  | 22:11:32.242 [main] INFO org.eclipse.jetty.server.Server - Started @2471ms
web_1  | 22:11:32.242 [qtp1315795813-24] DEBUG org.eclipse.jetty.util.thread.QueuedThreadPool - run [email protected]
web_1  | 22:11:32.242 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @2471ms [email protected][9.4.10.v20180503]
And nothing comes out when I go the url location.

mtnygard22:12:04

URL being something like http://localhost:4001/ ?

mtnygard22:12:32

Well, that was the obvious stuff. Give me a minute to try to replicate the problem.

mtnygard22:12:40

What OS are you on?

mtnygard22:12:30

Is your project.clj straight from the leiningen template?

yefoakira22:12:30

Linux Mint. Other than adding midje, yep.

mtnygard22:12:18

I've more or less reproduced the problem.

mtnygard22:12:30

I'm on Windows with WSL rather than Linux, so there's bound to be a little variation.

mtnygard22:12:37

Instead of connection reset, I get an empty response.

mtnygard22:12:30

The issue is that Jetty only binds to a server socket on "localhost".

mtnygard22:12:56

To get it to listen for connections on any other IP address than 127.0.0.1, you can set the ::http/host key to "0.0.0.0" in service.clj

👍 4
mtnygard22:12:12

With that, I'm able to get a good response from the host.

yefoakira22:12:28

Oooooohhh. Completely missed that. Thanks 😊