I am using docker to launch multiple instances of neo4j instances for my project. I have a requirement that I have to load a graph dump to one of my neo4j docker container and I have to do it again an again (as the graph dump will be provided by a separate group of people).
These are my steps that I have followed in order to do the same -
# docker run --publish=7474:7474 --publish=7687:7687 \
--volume=/home/dimension/neo4j/container3/data:/data \
--volume=/home/dimension/neo4j/container3/logs:/logs \
--volume=/home/dimension/neo4j/container3/conf:/conf \
--volume=/home/dimension/neo4j/container3/plugins:/plugins \
neo4j:3.3.3
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eee581b2f493 neo4j:3.3.3 "/docker-entrypoint.…" 2 hours ago Up 2 seconds 0.0.0.0:7474->7474/tcp, 7473/tcp, 0.0.0.0:7687->7687/tcp priceless_ride
This brings up the container, but the database is empty. Next I tried the following to load a neo4j dump to my newly built docker container
# docker stop priceless_ride
priceless_ride
# cp home/dimension/neo4j/dumps/2018-09-05.dump ~/neo4j/container3/data/
# docker run --publish=7474:7474 --publish=7687:7687 \
--volume=/home/dimension/neo4j/container3/data:/data \
--volume=/home/dimension/neo4j/container3/logs:/logs \
--volume=/home/dimension/neo4j/container3/conf:/conf \
--volume=/home/dimension/neo4j/container3/plugins:/plugins \
-i -t neo4j:3.3.3 /bin/bash
The above command creates a separate container and runs the container in interactive mode. Once I am inside the container I run -
bash-4.4# bin/neo4j-admin load --from=/data/2018-09-05.dump --database=graph.db --force
bash-4.4# exit
Now I execute docker ps -a
command, I will see 2 container in the output
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
073c31c75ff5 neo4j:3.3.3 "/docker-entrypoint.…" 8 seconds ago Exited (0) 3 seconds ago focused_zhukovsky
eee581b2f493 neo4j:3.3.3 "/docker-entrypoint.…" 3 hours ago Exited (0) 7 minutes ago priceless_ride
I have to remove the newly built container as it is no longer needed. by executing docker rm focused_zhukovsky
Every thing works fine, when I restarted my container by executing command
# docker start priceless_ride
and check the browser using http://127.0.0.1:7474/browser/
, the container now has the loaded database form the dump.
Following the above steps for loading a graph dump is okay, but its cumbersome if I have to do it again and again. Is their a cleaner way to load neo4j dump without the need to start a separate container in interactive mode and then firing neo4j-admin load
command.
Is it possible to start the docker container without running the neo4j inside it. If this is possible then I can go inside the container and fire the neo4j-admin load
command as many time I want.
I am stuck at this problem from quite some time. I will deeply appreciate any help on this issue.