title: Docker sqlite + Spring Boot
body: <p>I have a working Spring Boot application with sqlite. When I am trying to create a container I get the exception</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [clients]
  </code></pre>
  
  <p>It seems that the container can't access the database file.</p>
  
  <p>File structure is </p>
  
  <p><a href="https://i.stack.imgur.com/DPTbg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DPTbg.png" alt="enter image description here"></a></p>
  
  <p><code>Dockerfile</code></p>
  
  <pre><code>FROM openjdk:8
  ADD project-app.jar project-app.jar
  ADD mydb.db mydb.db
  ENTRYPOINT ["java","-jar","project-app.jar"]
  EXPOSE 8082
  </code></pre>
  
  <p><code>docker-compose.yml</code></p>
  
  <pre><code>version: '3.3'
  services:
      project-app:
        build: ./
        image: project-app:1.0
        restart: always
        container_name: project-app
        ports:
          - 8082:8082
        volumes: 
          - /var/run/docker.sock:/var/run/docker.sock
        network_mode: bridge
  </code></pre>
  
  <p>I tried adding the sqlite like a container, I also tried replicate MySQL configuration on <code>docker-compose.yml</code> but still got the same exception.</p>
  
  <p>Edit: After exploring the container it seems that the database file is present <code>mydb.db</code> but it's empty, that means Dockerfile doesn't copy the database.</p>
  
  <pre><code>    4 drwxr-xr-x   1 root root     4096 Sep  6 18:27 .
      4 drwxr-xr-x   1 root root     4096 Sep  6 18:27 ..
      0 -rwxr-xr-x   1 root root        0 Sep  6 18:27 .dockerenv
      4 drwxr-xr-x   1 root root     4096 Aug 14 11:23 bin
      4 drwxr-xr-x   2 root root     4096 Mar 28 09:12 boot
      0 drwxr-xr-x   5 root root      340 Sep  6 18:57 dev
      4 drwxr-xr-x   1 root root     4096 Sep  6 18:27 etc
      4 drwxr-xr-x   2 root root     4096 Mar 28 09:12 home
      4 drwxr-xr-x   1 root root     4096 Aug 12 00:00 lib
      4 drwxr-xr-x   2 root root     4096 Aug 12 00:00 lib64
      4 drwxr-xr-x   2 root root     4096 Aug 12 00:00 media
      4 drwxr-xr-x   2 root root     4096 Aug 12 00:00 mnt
      4 drwxr-xr-x   2 root root     4096 Aug 12 00:00 opt
      0 dr-xr-xr-x 145 root root        0 Sep  6 18:57 proc
      4 drwx------   1 root root     4096 Aug 14 11:25 root
      4 drwxr-xr-x   1 root root     4096 Sep  6 18:27 run
      4 drwxr-xr-x   1 root root     4096 Aug 14 06:24 sbin
  46260 -rwxr-xr-x   1 root root 47367833 Sep  6 17:02 project-app.jar
      0 -rw-r--r--   1 root root        0 Sep  6 18:27 mydb.db
      4 drwxr-xr-x   2 root root     4096 Aug 12 00:00 srv
      0 dr-xr-xr-x  13 root root        0 Sep  6 18:57 sys
      4 drwxrwxrwt   1 root root     4096 Sep  6 18:57 tmp
      4 drwxr-xr-x   1 root root     4096 Aug 12 00:00 usr
      4 drwxr-xr-x   1 root root     4096 Aug 12 00:00 var
  </code></pre>