But what about actually storing our data?

If you’d like to persist the database and logs outside of the container (this is a good idea), you just specify where you’d like to store that data using the -v option:

docker run \

-p 7474:7474 \

-p 7687:7687 \

-p 7473:7473 \

-v $HOME/neo4j/data:/data \

-v $HOME/neo4j/logs:/logs \

neo4j:3.0.6-enterprise

Step 4: Configuration

The Neo4j image by default declares a volume at /var/lib/neo4j/conf . This contains (depending on the version of Neo4j you’re using) all of Neo4j’s config files. For 3.X, this is a single file called “neo4j.conf”. To have our instances of Neo4j come up with the right configs, we have a few options:

We can just add your own configuration files as a volume at run-time with docker run -v /path/to/my/neo4j.conf:/conf/neo4j.conf .

. We could copy the file over when the container is started. To do that, copy your file into the build at a location which isn’t underneath the volume then call a script from the entrypoint or cmd which will copy the file to correct location and start Neo4j.

or which will copy the file to correct location and start Neo4j. We could also clone the project behind the Neo4j official image and edit the Dockerfile to add your own config file in before the VOLUME is declared (anything added before the VOLUME instruction is automatically copied in at run-time).

We could bring up an interactive “terminal” and then configure Neo4j from there.

Upon starting the container we can pass in environment variables (docs) e.g., --env = NEO4J_dbms_memory_pagecache_size = 4G



My preference is to store the .conf file outside of the container and then just point the container to the /conf/ directory on startup. This makes it a lot easier when spinning up a cluster (more on that in a follow-up blog post).

To do that, on startup we’ll use something like:

docker run \

-p 7474:7474 \

-p 7687:7687 \

-p 7473:7473 \

-v $HOME/neo4j/data:/data \

-v $HOME/neo4j/logs:/logs \

-v $HOME/neo4j/conf/:/conf/ \

neo4j:3.0.6-enterprise

Where in my root directory I have a folder called /neo4j/conf/ that has my desired configuration files.

Step 5: Interacting with Neo4j