This is not a duplicate of From inside of a Docker container, how do I connect to the localhost of the machine?. I have already attempted the suggestions in the aforementioned thread, and I know how to fix this problem in general. This problem seems to be specific to quarkus applications. I manage to make everything work except for the quarkus server.
Context
mvnw
, which I can use to start a development server by executing ./mvnw quarkus:dev -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=9000 -Ddebug=9001
in the host terminal.http://localhost:9000
in the browser. I can also do curl localhost:9000
and see that I get the HTML/CSS/JS code.Issue
I cannot reach the quarkus server from within a docker container. I have tried:
curl
container: docker run --rm -it --name curl --entrypoint sh curlimages/curl:latest
curl host.docker.internal:9000
-> Connection refusedcurl localhost:9000
-> Connection refusedcurl (the machine host name here):9000
-> Operation timed out (this happens for all ports)--network=host
, and use curl localhost:9000
-> Connection refusedHowever, I can connect to the JVM debug port using curl host.docker.internal:9001
(Empty reply from server), and I can also connect to a Python http fileserver (hosted from host) using the host.docker.internal
hostname. It seems to be that it is only the quarkus server that I cannot connect to.
What I want: A reliable way to connect to the host's quarkus container from within a docker container
System info
Could you try to disable the IPV6 on your wsl2 and repeat your test?
$ sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
$ sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
I had similar issues and this solved the problem for me.