Using Docker volume for '/data' directory does not persist the data

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:
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 icd10-populate-neo4j /var/lib/neo4j/import

All it does is copy the data files to Neo4j's import dir as well as a 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 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.

Hi, I'm doing this on Linux, it should function the same (more or less, PATH character issues aside). I'm curious, have you taken a look inside the docker container to look at the mount points, before and after stopping it? (from inside the container) You can run bash in the container to poke around a bit.

docker exec -it neo4j-test bash

take a look in the mount points to see what is there, I would add that in my experience the command df sometimes doesn't see the mount points (it should!), so to be sure I cd over to where they should be mounted to take a look and verify.