- 1 year ago
How to load dump file in neo4j running inside docker?
To load a Neo4j dump file into a Neo4j instance running inside a Docker container, you can follow these steps:
- Start the Neo4j Docker container: Run the following command to start the Neo4j container with the necessary ports mapped:
cssdocker run --name neo4j-container -p 7474:7474 -p 7687:7687 -d neo4j:latest
This command starts a Neo4j container named "neo4j-container" with ports 7474 (HTTP) and 7687 (Bolt) mapped to the corresponding ports on the host machine.
- Copy the dump file to the Docker container: Copy the Neo4j dump file (e.g.,
dump.db
) to the Docker container using thedocker cp
command:
bashdocker cp dump.db neo4j-container:/var/lib/neo4j/import/
This command copies the dump file to the /var/lib/neo4j/import/
directory inside the container.
- Access the Docker container's shell: Execute the following command to access the shell of the Docker container:
bashdocker exec -it neo4j-container /bin/bash
- Import the dump file using the
neo4j-admin
tool: Inside the container's shell, run theneo4j-admin
tool to import the dump file:
cssneo4j-admin load --from=/var/lib/neo4j/import/dump.db --database=neo4j --force
This command uses the --from
option to specify the path to the dump file, the --database
option to specify the target database name (e.g., neo4j
), and the --force
option to overwrite the existing database.
- Restart the Neo4j container: Restart the Neo4j container to apply the changes:
docker restart neo4j-container
After completing these steps, the Neo4j dump file should be loaded into the Neo4j instance running inside the Docker container. You can access Neo4j through the web interface by visiting http://localhost:7474
in your browser (or the corresponding IP address of your Docker host machine).
Please note that the above steps assume you have the necessary permissions to run Docker commands and access the Docker container. Adjust the commands as needed based on your specific setup and requirements.