docker

bherrmann 2019-03-10T18:02:06.003900Z

I’m a docker noob… on a mac 10.12.6 … and something isnt right…. any ideas?

$ lein new pedestal-service foof
$ cd foof
$ lein uberjar
$ docker build -t foof .
$ docker run -p 8080:8080 foof
(normal start up... output)
(in other terminal)
$ curl <http://localhost:8080>
curl: (52) Empty reply from server
If I run the app w/out docker,
$ curl <http://localhost:8080>
Hello World!
I also tried to get into the machine,
$ docker exec -t e18c937f3d99 ls /bin/sh
/bin/sh
but when I exec /bin/sh it seems to hang when executing a command….
docker exec -t e18c937f3d99  /bin/sh
/ # pwd
(hangs)

valtteri 2019-03-10T18:29:22.005Z

What does your Dockerfile look like?

bherrmann 2019-03-10T18:38:31.005400Z

It is the lein default…

$ cat Dockerfile  
FROM java:8-alpine
MAINTAINER Your Name &lt;you@example.com&gt;
ADD target/foof-0.0.1-SNAPSHOT-standalone.jar /foof/app.jar
EXPOSE 8080
CMD ["java", "-jar", "/foof/app.jar"]

valtteri 2019-03-10T18:46:39.006500Z

Hmm I tried it also and can confirm similar behavior. One moment I’ll try to debug what’s going on.

bherrmann 2019-03-10T18:51:03.006700Z

excellent

bherrmann 2019-03-10T18:52:11.007100Z

fyi

$ docker --version
Docker version 18.09.2, build 6247962

valtteri 2019-03-10T18:57:15.007800Z

I’m guessing it’s something like Pedestal accepts connections only from localhost. Digging still

bherrmann 2019-03-10T18:58:45.008700Z

that makes sense, although I thought the behavior of the hang when using /bin/sh seemed to hint that something else was wrong.

valtteri 2019-03-10T19:14:02.009500Z

docker exec -it 74ec6334588f /bin/sh works for me

valtteri 2019-03-10T19:14:09.009800Z

And uberjar seems to be running just fine

valtteri 2019-03-10T19:14:41.010700Z

I think there’s something in jetty configuration that doesn’t allow connections from anywhere else than localhost

valtteri 2019-03-10T19:22:09.011100Z

/ # telnet localhost 8080
GET / HTTP/1.1
HOST: localhost

HTTP/1.1 200 OK
Date: Sun, 10 Mar 2019 19:21:48 GMT
Strict-Transport-Security: max-age=31536000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Content-Security-Policy: object-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' 'strict-dynamic' https: http:;
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked

C
Hello World!
0

valtteri 2019-03-10T19:22:48.011700Z

That’s inside the container

bherrmann 2019-03-10T19:27:26.011900Z

humm…. https://github.com/pedestal/pedestal/issues/604

bherrmann 2019-03-10T19:32:25.012800Z

Changing the service.clj to enable

::http/host "0.0.0.0"
made it work!

🎉 1
valtteri 2019-03-10T19:34:24.013100Z

Excellent!

valtteri 2019-03-10T19:35:31.013800Z

I tried passing opts to jetty through ::http/container-options but that didn’t help. Glad you found the issue and was able to work it out!

valtteri 2019-03-10T19:38:06.015Z

Hopefully they’ll fix the template because it’s not an especially nice first experience. 😅

bherrmann 2019-03-10T19:40:30.016200Z

yea. I was expecting it to just work…. might be nice if the dockerfile had a comment about configuring pedestal

bherrmann 2019-03-10T19:40:38.016500Z

since I did look in there right away…

bherrmann 2019-03-10T20:20:32.016900Z

I took a stab at wording something up, https://github.com/pedestal/pedestal/pull/613