title: Connecting to postgres from a docker container
body: <p>I'm a little lost as to why my java application can't connect to my postgres database.  I'm aiming to connect to a postgres database through jdbc.  The application is to run inside a docker container.  </p>
  
  <pre><code>this.connection = `DriverManager.getConnection("jdbc:postgresql://&lt;myip&gt;:5432/databasename", "usr", "password");`
  </code></pre>
  
  <p>I'm getting the exception:</p>
  
  <pre><code>Connection refused.  Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
  </code></pre>
  
  <p>When I run the application from my desktop, it connects as expected.  When I run it from within the docker container, it fails.</p>
  
  <p>I've just installed docker this afternoon and ran through the getting started for windows, so my setup state is just after running that.  Here's the contents of my Dockerfile:</p>
  
  <pre><code>FROM java:8
  ADD VaultServer /
  EXPOSE 3971
  EXPOSE 3972
  ENTRYPOINT ["java", "-jar", "VaultServer.jar"]
  </code></pre>