Persist neo4j db data in docker container

Upon restarting the GCE instance, all db data is wiped from neo4j as the container is being rebuilt.
Find a way to persist this data, e.g. by mounting the graph.db directory to a location on the host system.

I've been trying to add a volume mount to the docker file

but data still didn't stay persistent after restarting the docker container

Does anybody have advice / tips ?

We don't want to dump the db rather make sure that after restarting the VM the data is still there. currently the graph.db folder is wiped because it's not mounted to the host system of the docker container

Can you show exactly what command you ran/how you mounted the volumes?
Did you follow the documentation? Docker - Operations Manual

Yes I did use the above mentioned documents :

--volume=$HOME/neo4j/data:/data \
    --volume=$HOME/neo4j/logs:/logs \
#!/bin/bash

docker build -t neo4j-image .
echo 'Image successfully built'
docker run \
    --publish=7474:7474 \
    --publish=7687:7687 \
    --volume=$HOME/neo4j/data:/data \
    --name neo4j-container \
    -e NEO4J_dbms_security_procedures_unrestricted=apoc.* \
    -e NEO4J_apoc_import_file_enabled=true \
    -e NEO4J_apoc_export_file_enabled=true \
    -e NEO4J_dbms_shell_enabled=true \
    -d neo4j-image
echo 'Container started'

When you do the "docker run" bit, how are you launching it on GCE? Like this directly?

For persistent data, you need to have a volume mapped to a GCE disk in the end. That mapping is why the data would persist after the docker container is gone. What have you tried there?

Doing the volume mounting as you have it here looks like the persistent volume is mapped to your personal client machine / laptop, nothing in GCP.

This is done directly on GCE , with in a Virtual machine on GCP ( thus mapping to a persistent volume on GCP)

Hope this makes sense


#!/bin/bash

docker build -t neo4j-image .
echo 'Image successfully built'
gcloud auth configure-docker
docker tag neo4j-image gcr.io/$1/neo4j-image:0.1
docker push gcr.io/$1/neo4j-image:0.1
echo 'Image successfully deployed to project $1'

OK -- so there's a bit to disentangle here hopefully I'm understanding this right.

You're running the docker command on a GCP VM. That GCP VM is backed by some GCP disk. On the GCP VM, you're mounting your data to $HOME/neo4j/data. So then it stands to reason that whatever GCP disk is backing your VM, your data is persisted there, at that path.

So is the data disappearing when you restart neo4j or what is the issue? A volume mount here is the right way to go.

1 Like

Exactly, sorry for tangling everything up :\

Data does not stay persistent after restarting the docker container

What does a volume mount entail ?