title: Connect to docker postgresql from mac without internet
body: <p>I use docker-compose up to start postgresql container. </p>
  
  <pre><code>version: '3.1'
  services:
    db:
      image: postgres
      restart: always
      environment:
        POSTGRES_USER: javauser
        POSTGRES_PASSWORD: javapass
        POSTGRES_DB: javadb
      ports:
        - "5432:5432"
  
    adminer:
      image: adminer
      restart: always
      ports:
        - 9090:9090
  </code></pre>
  
  <p>From my mac, I start java app </p>
  
  <pre><code>java -jar target/dummy.wallet-1.0-SNAPSHOT.jar server DummyWallet.yaml
  </code></pre>
  
  <p>It uses DB connection configuration as</p>
  
  <pre><code>database:
    # the name of your JDBC driver
    driverClass: org.postgresql.Driver
  
    # the username
    user: xxx
  
    # the password
    password: xxx
  
    # the JDBC URL
    url: jdbc:postgresql://0.0.0.0/xx
  </code></pre>
  
  <p>When my mac is connected to internet, connection works just fine.
  When my mac is NOT connected to internet, java throws no route to host error.</p>
  
  <pre><code>org.postgresql.util.PSQLException: The connection attempt failed.
  Caused by: java.net.NoRouteToHostException: No route to host  
  </code></pre>
  
  <p>I tried 127.0.0.1 and container name. Doesn’t work. How do I fix this?</p>