lein new pedestal-service my-app
cd my-app
lein uberjar
sudo docker build -t my-app .
docker run -p 8080:8080 my-app
But, when I navigate to localhost:8080 nothing is found by the browser. To be clear, I made no code changes from the default template.
Things I've tried, that did work:
- I've build another Docker image (based on Python).
- running `lein run`
- I've run the uberjar manually i.e. `java -jar "target/my-app-0.0.1-SNAPSHOT-standalone.jar`.
Things that didn't work include:
- Doing the same thing on a different OS. (Ubuntu vs. macOS)
- Switching to immutant and rebuilding, etc.
I've done this in the past, and it worked fine, but for some reason nothing I try to get Pedestal to run from Docker is working.
On 07/04/2018 12:56 PM, mbba...@gmail.com wrote:
I'm using the default Pedestal app, building an uberjar, building a Docker image, and attempting to run it. i.e. lein new pedestal-service my-app cd my-app lein uberjar sudo docker build -t my-app . docker run -p 8080:8080 my-app But, when I navigate to localhost:8080 nothing is found by the browser. To be clear, I made no code changes from the default template.
When I ran the same thing, I couldn’t reach the app either:
$ curl -I localhost:8080
curl: (56) Recv failure: Connection reset by peer
When running docker
containers, the error 56 usually means that the request went
through to localhost
,
but the containers bound to that port didn’t answer anything.
The default template
listen only for localhost
,
not 0.0.0.0
.
However, localhost
means inside the container, not outside of it.
Try changing the ::http/host
commented config in src/my_app/service.clj
from "localhost"
to "0.0.0.0"
(a sample patch is attached).
After that, the container started answering properly:
$ curl localhost:8080
Hello World!
Maybe this should be the default?