Stardog VOLUME configuration with Vagrant/Docker

39 views
Skip to first unread message

Timmy Storms

unread,
Jan 7, 2016, 11:08:14 AM1/7/16
to Vagrant
Hi,

I'm trying to set up a Stardog container with Vagrant/Docker. The biggest challenge is to setup a volume that keeps changed data (e.g. persisted RDF data), even after a container restart. When I don't use VOLUME's, Stardog starts just fine but won't keep its persisted data. When I do use a VOLUME, Stardog even fails to load. This is how I've setup the environment.

To create a virtualbox machine, I'm using the following Vagrantfile (initialized with vagrant up)

Vagrant.configure("2") do |config|
 config
.vm.box = "ubuntu/trusty64"
 config
.vm.hostname = "dh01"
 config
.vm.provision "docker"
 
 config
.vm.provision "shell", inline:
   
"ps aux | grep 'sshd:' | awk '{print $2}' | xargs kill"
 
 config
.vm.provider "virtualbox" do |v|
 v
.name = "vagrant_docker_host"
 v
.memory = 2048
 v
.cpus = 2
 
end
 
 config
.vm.network "forwarded_port", guest: 5820, host: 5820
end

As the persisted RDF data should still be available when a Stardog container is reloaded, a data container is created to keep a volume.

config.vm.define "data_container" do |v|
    v
.vm.provider "docker" do |d|
      d
.vagrant_vagrantfile = "./docker/Vagrantfile"
      d
.name = "data_container"
      d
.image = "busybox"
      d
.remains_running = false
      d
.create_args = ["--entrypoint", "/bin/true"]
   d
.volumes = [
 
"/data/stardog/:/data/stardog"
   
]
   
end
end

The Stardog container is started with the following Vagrantfile that points to given Dockerfile:

config.vm.define "stardog" do |v|
    v
.vm.provider "docker" do |d|
      d
.vagrant_vagrantfile = "./docker/Vagrantfile"
      d
.build_dir = "./stardog"
      d
.name = "stardog"      
      d
.ports = [ '5820:5820' ]
  d
.remains_running = true
  d
.create_args = ["--volumes-from=data_container"]
   
end
end


FROM java:openjdk-7-jdk

ENV STARDOG_VER stardog
-3.1.3
ENV STARDOG_HOME
/data/stardog

WORKDIR
/

COPY $
{STARDOG_VER}.zip /
RUN unzip $
{STARDOG_VER}.zip

COPY stardog
.properties ${STARDOG_HOME}/
COPY stardog
-license-key.bin ${STARDOG_HOME}/

EXPOSE
5820

WORKDIR
/${STARDOG_VER}

CMD bin
/stardog-admin server start && (tail -f $STARDOG_HOME/stardog.log &) && while (pidof java > /dev/null); do sleep 1; done

With given configuration, the two COPY statements seem to be ignored. Both files aren't copied and that causes Stardog to fail on initialization. As to no surprise, the destination folder corresponds to the folder that is defined in the volume argument.

When I leave out the entry "d.create_args = ["--volumes-from=data_container"]", Stardog loads fine but won't "remember" its data after a restart. So to summerize, I'm trying to use a volume with a folder /data/stardog in the docker VM that synchronizes with a folder /data/stardog in the stardog container. Any help is appreciated!
Reply all
Reply to author
Forward
0 new messages