How to set up persistent configuration using the Docker Hub Deployment
How would you approach configuring a docker-compose version of using the Docker Hub Deployment method for the server?
By default all data is reset after shutting down the container. The configuration to store an application.yaml configuration file does not work outside of Docker Swarm environments, since configs isn't supported for non-swarm deployments.
Just mapping the configuration file into the container under /data/hapi/application.yaml doesn't work either.
Is there a method to get the H2 database to be stored in a persistent volume?
Oh my, I have been spending too much time trying to do same. I can't get either docker-compose or docker initialize the data store outside the container and it resets db to empty at start. Have you been able to resolve this yet?
What does your Volume mapping look like in your YAML file?
I use this approach and it maintains the data in the externally-mapped db folder:
volumes:
- db:/home/smile/smilecdr/database
- log:/home/smile/smilecdr/log
When I accept the default spring.datasource : url: 'jdbc:h2:file:./target/database/h2' then try to mount the volume with docker-compose, I get permission errors: Access Denied to individual files in h2 container directory
volumes:
- db:/app/target/database/h2
With plain docker it appears to mount w/o errors, but nothing shows up in my local file system, so I don't think it is actually trying to get to those files.
I also am not using swarm deployment.
While data will persist within the container across docker start/stop cycles, it is not using the volume so I can't persist it outside of the container itself.
I can't get shell access to this container either ... is there a shell path?
@szitello
You might have to create that db folder in your host machine before starting up the container. This might also require altering some permissions for accessing that folder. I am not sure if that h2 folder is included or not, so it's best to shell into the container and verify the full path.
To get shell access you can just use something like:
docker exec -it <CONTAINER_ID> /bin/bash
Are you able to get shell access in your container? I am not. I havetried /bin/bash /bin/sh /bin/ash . I assume its not in the container.
I am curious about your db volume. Why are you using /home/smile/smilecdr/database ?
Did you specify that in application.yaml?
I have tried using jdbc values other than the default and while the application starts up OK, I get nothing attaching to the volume mount.
Are you using the Docker Hub or did you build the docker image locally?
Closing as stale
The default configuration places H2 database in memory, see https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/5ee2e4796ed67240d4ef00dfa2c029ae895ce0e3/src/main/resources/application.yaml#L47