I have been trying off and on for a couple of months to use Docker volumes to persist Neo4j data on the host machine but I cannot get it to work no matter what I try. I do not know if it is a Docker or a Neo4j problem, but thought I would start here since I have no problem with Docker volumes with anything other than Neo4j.
Neo4j: 3.5.8
OS: Windows 10
Docker Desktop: 2.3.0.3
Docker Engine: 19.03.8
I'm building an image with this simple Dockerfile:
FROM neo4j:3.5.8
COPY auth /data/dbms/auth
COPY populate-neo4j.sh /populate-neo4j.sh
COPY icd10-populate-neo4j /var/lib/neo4j/import
All it does is copy the data files to Neo4j's import
dir as well as a populate-neo4.sh
script that performs the actual import after the container is running.
Then I use
docker run -itd --name neo4j-test -p 7474:7474 -p 7687:7687 -v c:/neo4j/logs:/logs -v c:/neo4j/data:/data adj7388/nchs-neo4j
to map the container's /data
dir to c:\neo4j\data
on the host machine, like this:
Then I use docker exec ...
to run the populate-neo4j.sh
script in the container, and I can see it's working:
When the script finishes, sure enough I see the data in the browser interface:
And it appears to be storing the data on the host machine:
Then I stop and restart the container:
Now there is no data showing in the browser:
c:\neo4j\data\databases\graph.db
and all its data are still present on the host machine directory, and even if I remove the container then run the same docker run ...
command as above, the container still doesn't use (or find?) the data in the volume. The graph is just empty.
What am I doing wrong?
Thank you.