Hi,
I'd like to copy a dump file to a docker container and load it using neo4j-admin load
as part of an extension script in my docker container.
In particular I have the following workflow
Start an empty Neo4j community instance:
docker run \
--detach \
--name=neo4j-analyse \
--publish=7687:7687 \
--volume=$PWD/data:/data \
--env NEO4J_AUTH=neo4j/neo5j \
neo4j
Run a process which populates the database
Stop the neo4j-analyse
instance:
docker stop neo4j-analyse
Dump the data to a local file:
docker run --interactive --tty --rm \
--volume=$PWD/data:/data \
--volume=$PWD/dump:/dump \
--user="$(id -u):$(id -g)" \
neo4j \
neo4j-admin dump --database=neo4j --to=/dump/db.dump
Build a Neo4j image which contains the dump file and populates the database at startup:
docker build --tag neo4j-model .
The directory for the docker build contains the dump file db.dump
, the Dockerfile
:
FROM neo4j
COPY db.dump /db.dump
COPY extension-script.sh /extension-script.sh
ENV EXTENSION_SCRIPT=/extension-script.sh
and the extension-script.sh
:
#!/bin/sh
neo4j-admin load --from=/db.dump --database=neo4j --force
Start the final docker container:
docker run \
--detach \
--name=neo4j-model \
--publish=7474:7474 --publish=7687:7687 \
--env NEO4J_AUTH=none \
--env NEO4J_dbms_read__only=true \
neo4j-model
I can see in the log that the dump file is loaded and Neo4j is started. If I want to connect with the Neo4j browser, I get the following error:
ERROR DatabaseNotFoundError
Database "neo4j" is unavailable, its status is "offline."
What am I doing wrong? Any hints suggestions and ideas are highly appreciated!
Thanks Harald