patterndockerMinor
Persist Changes to New Docker Image - neo4j
Viewed 0 times
imagenewdockerneo4jchangespersist
Problem
I am trying to create a new image based on the
I have these goals:
I am using
Windows 10
Docker Community Edition Version 18.06.0-ce-win72 (19098)
Here is what I have tried:
I used this docker-compose.yml:
-
Load data into the database using a script run on my host. I verified that the database now contains nodes and relationships.
-
Commit the container to an image.
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.
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:
- Start a container from neo4j:latest.
I used this docker-compose.yml:
version: "3"
services:
neo4j:
image: neo4j:latest
ports:
- "7474:7474"
- "7687:7687"
networks:
webnet:- Connect to neo4j using a browser. I set a new password, as is required.
http://localhost:7474/browser/-
Load data into the database using a script run on my host. I verified that the database now contains nodes and relationships.
-
Commit the container to an image.
docker commit --author="Jacob Quisenberry" c5c3f2998895 jquisenberry/graphdb:latest- Push the image to my repository.
docker push jquisenberry/graphdb:latest- Run the image
docker run --expose=7474 --expose=7687 -p 7474:7474 -p 7687:7687 jquisenberry/graphdb:latest- 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.
Solution
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
Note, the
Edit1
To set password, the Insallation: Docker mentions as
By default Neo4j requires authentication and requires you to login with
You can set the password for the Docker container directly by specifying
Then the docker run should be
Anyhow for the
/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 \
neo4j:latest
Note, the
/path/to/neo4j is a physical directory on the host machine.Edit1
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/ 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/ \
--volume=/path/to/neo4j/data:/data \
--volume=/path/to/neo4j/logs:/logs \
neo4j:latest
Anyhow for the
/data, I only achieve with mounting it to the host machine.Context
StackExchange DevOps Q#4806, answer score: 1
Revisions (0)
No revisions yet.