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)
What does your Dockerfile look like?
It is the lein default…
$ cat Dockerfile
FROM java:8-alpine
MAINTAINER Your Name <you@example.com>
ADD target/foof-0.0.1-SNAPSHOT-standalone.jar /foof/app.jar
EXPOSE 8080
CMD ["java", "-jar", "/foof/app.jar"]
Hmm I tried it also and can confirm similar behavior. One moment I’ll try to debug what’s going on.
excellent
fyi
$ docker --version
Docker version 18.09.2, build 6247962
I’m guessing it’s something like Pedestal accepts connections only from localhost. Digging still
that makes sense, although I thought the behavior of the hang when using /bin/sh seemed to hint that something else was wrong.
docker exec -it 74ec6334588f /bin/sh works for me
And uberjar seems to be running just fine
I think there’s something in jetty configuration that doesn’t allow connections from anywhere else than localhost
/ # 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
That’s inside the container
Changing the service.clj to enable
::http/host "0.0.0.0"
made it work!Excellent!
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!
Hopefully they’ll fix the template because it’s not an especially nice first experience. 😅
yea. I was expecting it to just work…. might be nice if the dockerfile had a comment about configuring pedestal
since I did look in there right away…
I took a stab at wording something up, https://github.com/pedestal/pedestal/pull/613