Can't access host machine from docker toolbox

73 Views Asked by At

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:

  1. Use host ip to access Database and It's working but if there's a connectivity issues, I can't connect to the DB.
  2. I tried also this command host.docker.internal:host-gateway but I got invalid IP address in add-host: "host-gateway".
  3. I tried to access DB using hostname instead of hostip but don't work.
0

There are 0 best solutions below