I am trying to create a new image based on the neo4j:latest image. What is the proper way to persist to a new image and run a container based on the image?

I have these goals:

  • Save the new password I assigned to the database.
  • Keep data stored in the database.

I am using Windows 10 Docker Community Edition Version 18.06.0-ce-win72 (19098)

Here is what I have tried:

  1. Start a container from neo4j:latest.

I used this docker-compose.yml:

version: "3"
    image: neo4j:latest
      - "7474:7474"
      - "7687:7687"    
  1. Connect to neo4j using a browser. I set a new password, as is required.


  1. Load data into the database using a script run on my host. I verified that the database now contains nodes and relationships.

  2. Commit the container to an image.

docker commit --author="Jacob Quisenberry" c5c3f2998895 jquisenberry/graphdb:latest

  1. Push the image to my repository.

docker push jquisenberry/graphdb:latest

  1. Run the image

docker run --expose=7474 --expose=7687 -p 7474:7474 -p 7687:7687 jquisenberry/graphdb:latest

  1. Connect using a browser.

I expected not to have to enter a new password and for my data to be intact.Instead, I am required to enter a new password. My database now lacks nodes and relationships.

1 Answer 1


Regarding to Neo4j with Docker and Insallation: Docker

/data to allow the database to be persisted outside its container.

/logs to allow access to Neo4j log files.

I understand that we should mount the /data to the host machine so that the new password is persisted as the following example.

docker run \
    --publish=7474:7474 --publish=7687:7687 \
    --volume=/path/to/neo4j/data:/data \
    --volume=/path/to/neo4j/logs:/logs \

Note, the /path/to/neo4j is a physical directory on the host machine.


To set password, the Insallation: Docker mentions as

By default Neo4j requires authentication and requires you to login with neo4j/neo4j at the first connection and set a new password.

You can set the password for the Docker container directly by specifying --env NEO4J_AUTH=neo4j/<password> in your run directive. Alternatively, you can disable authentication by specifying --env NEO4J_AUTH=none instead.

Then the docker run should be

docker run \
    --publish=7474:7474 --publish=7687:7687 \
    --env NEO4J_AUTH=neo4j/<password> \
    --volume=/path/to/neo4j/data:/data \
    --volume=/path/to/neo4j/logs:/logs \

Anyhow for the /data, I only achieve with mounting it to the host machine.

  • Is there any way to write those volume options to an image, or is the only option to include the --volume switch each time the container is started. Commented Aug 22, 2018 at 6:02
  • There is a way for setting the initial password, but I have not achieved with the /data. Please see my edit1. Commented Aug 22, 2018 at 7:22
  • I think that the solution for the disabling authentication will satisfy my use case. For the problem of persisting data and settings, I suspect that I have to export a value to TAR. As far as I know there is no way to push a volume to Docker hub. Commented Aug 22, 2018 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.