How do you perform a dump of a Neo4j database within a Docker container?
Solution 1:
1: Stop the container.
docker stop myname-neo4j
2: Remove the container
docker rm myname-neo4j
3: Run the container as interactive mode (-it) without the option (detach) and executing the shell ( /bin/bash ).
docker run \
--publish=7474:7474 \
--publish=7473:7473 \
--publish=7687:7687 \
--volume=$HOME/neo4j/data:/data \
--volume=$HOME/neo4j/logs:/logs \
--volume=$HOME/neo4j/ssl:/ssl \
--ulimit=nofile=40000:40000 \
--name=myname-neo4j \
-it \
neo4j:3.1.1 \
-c /bin/bash
Now you are inside the neo4j container without running Neo.
4: Check that neo is not up by visiting the URI endpoint in (http://yourhost:7474). You should see the "Unable to connect" message.
5: Dump your database
docker exec -ti myname-neo4j bin/neo4j-admin dump --database=graph.db --to=/home/name/myname.dump
Solution 2:
I did this:
docker stop [neo4j container]
docker run --name dump --entrypoint="/bin/bash" -it -v $HOME/neo4j/data:/data neo4j:3.1.1 -c "neo4j-admin dump --to=/data/db.dump"
docker start [neo4j container]
Then you can either keep the "dump" container and reuse it, or just remove it. Same concept with the entrypoint and -c parameter would apply for the load procedure.