I have installed Docker Toolbox on windows server 2016. I have also containerized my spring boot application and my Database is running as standalone application on the host machine not as a container. I want to access the Database whether I am online or offline using localhost.
docker compose.yaml
version: "3.3"
services:
engine:
image: myimages23.azurecr.io/myimages23:Hyperbill-Engine-3719
container_name: Engine
ports:
- 8086:8003
#network_mode: host
# extra_hosts:
# - "host.docker.internal:host-gateway"
# extra_hosts:
# - "dockerhost:$DOCKERHOST"
application-properties.yml
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:sqlserver://192.168.1.20:1433;database=my-db-test
username: username
password: password
Here's what I have tried so far:
- Use host ip to access Database and It's working but if there's a connectivity issues, I can't connect to the DB.
- I tried also this command
host.docker.internal:host-gatewaybut I gotinvalid IP address in add-host: "host-gateway". - I tried to access DB using
hostnameinstead ofhostipbut don't work.