I have a Spring Boot config server running in localhost on port 8888. I'd like to access this service from inside a docker container. I cannot put this service inside the same docker-compose and in the same network.
Service: http://localhost:8888/cpo-executor/dev
Using my ip: http://192.168.0.6:8888/cpo-executor/dev
I've checked this address on browser and it's working. When I try to access from inside a docker container I got an error:
docker exec -it 7febe846f2ea /bin/bash
curl http://192.168.0.6:8888/cpo-executor/dev
Error:
curl: (7) Failed to connect to 192.168.0.6 port 8888: Connection timed out
I've tried to start my containers putting "network_mode: host" in docker-compose but I ended up falling into another error, from one container not communicating with another.
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Caused by: java.net.UnknownHostException: mysql
How can I access a service from host from inside a docker container?