Infinispan server standalone as a docker swarm service using bind mount to persist file-store to host
prateekk.in Oct 8, 2018 9:21 PMI am deploying the Infinispan server 9.3.2.Final (https://hub.docker.com/r/jboss/infinispan-server/) in a service stack (using docker compose v3 format) on a docker host in a swarm cluster (on premise for now).
It will run in standalone mode using a custom xml file as input (which will create a local cache) and then the other services in the application stack will connect to it using RemoteCacheManager (the ConfigurationBuilder host will take the service name as input).
In case this infinispan service were to crash (and docker swarm will launch it again), I'd like the file-store in the service to persist and be available on the docker host file path. This will ensure that when the service is automatically restarted, it will pre-load itself from the file-store that stayed safe on the docker host's file system (and will again be available as a bind mount).
The problem is that in standalone mode, in the xml file, the file-store path= is relative to the /opt/jboss/infinispan-server/standalone/data and its not possible to specify this as a volume mount on the host (as the host would not have the full folder structure on its file system that the container expects).
I tried using <global state><persistent location="/path/to/where"></global-state> but still my file store remains relative to /opt/jboss/infinispan-server/standalone/data. Am hoping someone could please advise on how this can be done, here is our deployment:
$docker stack deploy -c docker-compose-ourApp.yml ourAppStack
version: "3" services: infinispan: image: jboss/infinispan-server:9.3.2.Final command: standalone -c custom/infinispan_server.xml environment: - APP_USER=ourApp - APP_PASS=changeme - MGMT_USER=ourApp - MGMT_PASS=changeme ports: - "9990:9990" volumes: - "/c/Users/someone/DockerMapped/datafiles/configuration/:/opt/jboss/infinispan-server/standalone/configuration/custom/" networks: - ourOverlayNetworkName networks: ourOverlayNetworkName:
Here is the relevant part from /c/Users/someone/DockerMapped/datafiles/configuration/infinispan_server.xml
<subsystem
xmlns="urn:infinispan:server:core:9.3" default-cache-container="local">
<cache-container name="local" default-cache="default" statistics="true">
<global-state/>
<local-cache name="default"/>
<local-cache name="APP_CACHE">
<expiration lifespan="-1"/>
<file-store path="ourAPP/APP_CACHE" max-entries="-1" purge="false" passivation="false"/>
<memory>
<binary size="100000000" eviction="MEMORY"/>
</memory>
</local-cache>
</cache-container>
</subsystem>
From some googling I think it might be possible via some of these but I am not able to get it working:
- some settings in global-state like for e.g:
<global-state>
<persistent-location path="/path/to/where" />
<temporary-location path="/path/to/where/tmp"/>
</global-state>
- Volume mount: by creating a volume in docker (say named cachedata:) and then providing a volume mount in the compose file.
Thanks,
_prateek