title: Connecting to an H2 Database in a Docker Container
body: <p>I have a basic Spring Boot Data JPA project.  The h2 database that I'm connecting to is located at <code>/tmp/customerdb.h2.db</code>.  When running the application using <code>mvn spring-boot:run</code> everything works fine.  The application connects to the database, adds records, and prints the added records to the console.</p>
  
  <p>I then build a docker container, and run it.  The docker file looks like this:</p>
  
  <pre><code>FROM java:8
  VOLUME /tmp
  ADD jpa-docker-1.0.0.jar  app.jar
  RUN bash -c 'touch /app.jar'
  ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar",/app.jar"]
  </code></pre>
  
  <p>When I run the container I get the following error:</p>
  
  <pre><code>2015-06-12 19:25:57.200  WARN 1 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 42102, SQLState: 42S02
  2015-06-12 19:25:57.200 ERROR 1 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : Table "CUSTOMER" not found; SQL statement:
  </code></pre>
  
  <p>So it looks like the application can't see the database.  The connection URL looks like this:
  <code>spring.datasource.url=jdbc:h2:/tmp/customerdb</code></p>
  
  <p>As I mentioned, this works fine when running outside the docker container.  I'm assuming that the line in the Dockerfile <code>VOLUME /tmp</code> creates the <code>/tmp</code> directory inside the container, along with all the files it contains, such that the database is visible, but this seems like it's not working.  Thoughts?</p>
  
  <p>TIA,
  - Ole</p>