Reputation: 1623
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
Upvotes: 3
Views: 2922
Reputation: 690
I had the same problem and was misled by the answer here, which is only because I have missed one detail in the question. Without this detail, I ran into the exact same issue, but setting IPv4 has not solved the problem (though starting quarkus from an uber-jar fixed the issue).
However, I just want to emphasize, that not setting quarkus.http.host=0.0.0.0
leads to the same problem described in the question.
(Perhaps this will help another less thorough reader of the question.)
By default, quarkus is Listening on: http://localhost:8080
, which will not be sufficient to call it from a docker container.
So, the quarkus.http.host
is necessary here.
See also How to make Quarkus to listen on all network interfaces instead of localhost?.
Upvotes: 1
Reputation: 1753
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.
Upvotes: 2