I'm working on Spring-boot app I want it to connect to the local's database from the insider docker containers. I'm using Ubuntu 18 and 1.28 for docker-compose. I have found several solutions but no luck on me,
Below are the solutions I've found on the Stackoverflow but it's not working,
- network_mode: "host"
:
version: "3"
services:
partner:
container_name: customer
image: cms/customer-service
build:
context: cms-customer-service/
ports:
- "8003:8000"
restart: always
network_mode: "host"
networks:
- api_network
networks:
api_network:
driver: bridge
This solution throws the error
'ERROR: 'network_mode' and 'networks' cannot be combined'
But If I remove the networks, how can the Docker Containers connect to each other ? Then I removed the "networks:" part, so I got this error
docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings
- host.docker.internal
I got "Connection to host.docker.internal:5432 refused" If I used host.docker.internal instead of localhost.
Please help.