I am developing a Spring Boot application using IntelliJ. This application depends on several other applications that are deployed in docker containers.
As there is a lot of communication going on, I need to enable an application inside docker to connect to my application running on localhost.
I have seen lots of people say you need to use host.docker.internal
but this didn't work.
What I have tried:
- Configuring my local application to bind to
0.0.0.0
viaserver.address: 0.0.0.0
- Configuring my docker container with
extra_hosts=host.docker.internal:host-gateway
- Putting
127.0.0.1 host.docker.internal
in myhosts
file
Nonetheless nothing worked, I'm always getting Connection refused
when trying to reach my local application from within docker.
As I'm working in a team, I need a solution that works out of the box for everyone, so no solution tied to my specific computer. Because I have seen people using the IP of their local machine and stuff in order to make it work. So hostname resolution host.docker.internal
would be ideal - if it worked..
I have browsed lots of topics on stackoverflow but none of the answers worked for me, so thats why I decided to create a new question.
I am using:
- Windows 10 Version 21H2 Build 19044.2251
- Ubuntu 20.04 WSL2
- Docker version 20.10.22, build 3a2c30b