Environment:
Docker Mac Desktop: 4.2.0
MacOS: 11.6.1
Expected Behavior:
I build a java server image and use docker-compose -f docker/docker-compose.yml up to run a java server, and try to access it from my laptop's localhost:9090. I am expecting curl -i -X GET http://localhost:9090/heanthz will return 200.
Actual Behavior:
curl -i -X GET http://localhost:9090/heanthz will return curl: (52) Empty reply from server.
docker-compose.yml look like this:
version: '3'
services:
database:
image: "postgres" # use latest official postgres version
ports:
- "5432:5432"
env_file:
- dev-postgres.env # configure postgres
volumes:
- ./dev-postgres-data:/var/lib/postgresql/data/ # persist data even if container shuts down
redis:
image: "redis:alpine"
clickhouse:
image: "clickhouse/clickhouse-server"
ports:
- "8123:8123"
server:
image: "test-server"
depends_on:
- database
- redis
- clickhouse
ports:
- "9090:9090"
entrypoint: /bin/sh
command: -c "java -cp test-server.jar app.core"
env_file:
- dev-server.env
Some behavior I found:
if I get into the docker instance (docker exec -it docker-server-1 sh), and access http://localhost:9090/heanthz, it will return 200
on my laptop
$lsof -i:9090
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
com.docke 44140 joe 238u IPv6 0x48c9c413c17d3d1b 0t0 TCP *:websm (LISTEN)
I think in your server instead of using the ip as localhost or 127.0.0.1 you have to use 0.0.0.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With