A Neo4j container (docker) with initial data in it

Other database dockers that I’ve worked with (like Postgres) have a mechanism to import some initial data into their empty instance once the container starts for the first time. This is usually in form of putting your SQL files in a specific folder.

I need to do the same for Neo4j. I want to compose a Neo4j docker image with some data in it. What’s the right way to do this?

  • Mysql container can not mount data to a nfs folder
  • Running angular2 webpack app with busybox httpd in docker
  • How to convert docker run command into json file?
  • flink on docker disk full
  • How to pass multiple properties files for multiple web applications in single docker?
  • Docker: How to start service as root
  • 'clear' doesn't clean the screen when I run docker on Windows Command Prompt
  • Unable to access jarfile - Docker on Elastic Beanstalk
  • How to properly run a Docker container as a specific host user with the same groups?
  • Docker container can not be found using curl
  • Docker unable to process Dockerfile
  • How to run jar file using docker file in docker container
  • One Solution collect form web for “A Neo4j container (docker) with initial data in it”

    This could be achieved…
    There are 2 requirements:

    1. set initial password, which could be achieved using bin/neo4j-admin set-initial-password <password> and then
    2. import data from file in cypher format cat import/data.cypher | NEO4J_USERNAME=neo4j NEO4J_PASSWORD=${NEO4J_PASSWD} bin/cypher-shell --fail-fast

    Sample Dockerfile may look like this

    FROM neo4j:3.2
    ENV NEO4J_PASSWD neo4jadmin
    COPY data.cypher /var/lib/neo4j/import/
    VOLUME /data
    CMD bin/neo4j-admin set-initial-password ${NEO4J_PASSWD} || true && \
        bin/neo4j start && sleep 5 && \
        for f in import/*; do \
          [ -f "$f" ] || continue; \
          cat "$f" | NEO4J_USERNAME=neo4j NEO4J_PASSWORD=${NEO4J_PASSWD} bin/cypher-shell --fail-fast && rm "$f"; \
        done && \
        tail -f logs/neo4j.log

    Building image sudo docker build -t neo4j-3.1:loaddata .

    And running container docker run -it --rm --name neo4jtest neo4j-3.1:loaddata

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.