2

I'm trying to make a docker-compose file that starts a Neo4J database and loads a dump file in for immediate use. I dislike installing database systems locally when they are usually just as easy to toss in a docker file, and then are easier to handle and wipe out when needed. However, I just can't seem to get this working. When running instructions I've found online, the docker container just fails to start, without any sort of error message.

Docker-Compose.yml

version: '3.7'

services:
  neo4j:
    container_name: 'neo4j'
    image: neo4j:latest
    environment:
      - NEO4J_AUTH=neo4j/password
      - EXTENSION_SCRIPT=/neo4j-data/neo4j-init.sh
    ports:
      - "7474:7474"
      - "7687:7687"
    volumes: 
      - ./neo4j-data:/data

neo4j-init.sh:

#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

# do not run init script at each container strat but only at the first start
if [ ! -f /tmp/neo4j-import-done.flag ]; then
    /var/lib/neo4j/bin/neo4j-admin neo4j-admin load --from=/data/data.dump --database=graph.db --force
    touch /tmp/neo4j-import-done.flag
else
    echo "The import has already been made."
fi

This was built entirely from here, and I've followed those instructions exactly, as far as I can tell.

Devildude4427
  • 892
  • 1
  • 8
  • 28

2 Answers2

1

For anyone still searching, you need to restore ownership of the /data folder to neo4j

Add this line after database load in neo4j-init.sh

chown -R neo4j /data
Jerry
  • 563
  • 1
  • 6
  • 22
-1

You may find the following article helpful - it describes how to do exactly what you're trying to do

Lju
  • 582
  • 2
  • 6