title: Java app in docker: Failed to get driver instance for postgres
body: <p>I created a java web app. When I run java -jar xxx.jar on host, it can connect to Postgres DB on my host without any issue. But my app can not get driver instance for the same jdbc URL when it runs in a docker container I created. The error is:</p>
  
  <blockquote>
    <p>java.lang.RuntimeException: Failed to get driver instance for 
    jdbcUrl=’jdbc:postgresql://ip_of_my_host:5432/srr’</p>
  </blockquote>
  
  <p>This is how I run docker image:</p>
  
  <pre class="lang-sh prettyprint-override"><code>docker run -p 4567:4567 \
    -e JP_RESULTS_DB_URL=’jdbc:postgresql://ip_of_my_host:5432/srr’ \
    -e JP_RESULTS_DB_USERNAME=my_username \
    -e JP_RESULTS_DB_PASSWORD=my_password \
    -it id_of_image
  </code></pre>
  
  <p>4567 is the port number of my Rest API server. Do I need to also set porting for 5432? If I add "-p 5432:5432", I got error it is already allocated so I didn't add this port to docker run.</p>
  
  <p>What could be the problem? Is it the driver issue or port issue or something else?</p>
  
  <p>I haven't found any useful answers here yet so I have to ask. </p>