Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping an existing local neo4j database to a neo4j docker container [OSX] #66

Closed
alexjajones opened this issue Nov 13, 2016 · 4 comments

Comments

@alexjajones
Copy link

alexjajones commented Nov 13, 2016

I seem to be having troubles mapping a local database to the docker container. I have exhausted google and stackoverflow after hours of search and still can't get it working. Im wondering if there's an issue or am I just barking up the wrong tree.

Here is my docker-compose.yml:

version: '2'
services:
  neo4j:
    image: neo4j
    ports:
     - "7474:7474"
    volumes:
      - /User/testuser/Documents/Neo4j/epe.graphdb/data:/data
    environment:
       NEO4J_AUTH: neo4j/neo4j

When using the desktop application for neo4j, setting the database location to the following works perfect and I can browse the data. But the browser within the docker container returns no data.

/User/testuser/Documents/Neo4j/epe.graphdb

Sorry if this is just me being stupid, close if this is the case.

@spacecowboy
Copy link
Contributor

It looks like you a trying to pass the wrong directory to the container. You want to pass the raw data directory and not the graph.db directory.

To illustrate, this is the default structure of the /data directory:

/data
└── databases
    └── graph.db
        ├── index
        ├── neostore
        ├── neostore.counts.db.a
        ├── neostore.id
        ├── neostore.labeltokenstore.db
        ├── neostore.labeltokenstore.db.id
        ├── neostore.labeltokenstore.db.names
        ├── neostore.labeltokenstore.db.names.id
        ├── neostore.nodestore.db
        ├── neostore.nodestore.db.id
        ├── neostore.nodestore.db.labels
        ├── neostore.nodestore.db.labels.id
        ├── neostore.propertystore.db
        ├── neostore.propertystore.db.arrays
        ├── neostore.propertystore.db.arrays.id
        ├── neostore.propertystore.db.id
        ├── neostore.propertystore.db.index
        ├── neostore.propertystore.db.index.id
        ├── neostore.propertystore.db.index.keys
        ├── neostore.propertystore.db.index.keys.id
        ├── neostore.propertystore.db.strings
        ├── neostore.propertystore.db.strings.id
        ├── neostore.relationshipgroupstore.db
        ├── neostore.relationshipgroupstore.db.id
        ├── neostore.relationshipstore.db
        ├── neostore.relationshipstore.db.id
        ├── neostore.relationshiptypestore.db
        ├── neostore.relationshiptypestore.db.id
        ├── neostore.relationshiptypestore.db.names
        ├── neostore.relationshiptypestore.db.names.id
        ├── neostore.schemastore.db
        ├── neostore.schemastore.db.id
        ├── neostore.transaction.db.0
        ├── schema
        │   └── label
        │       └── lucene
        │           └── labelStore
        │               ├── 1
        │               │   └── write.lock
        │               └── failure-message
        └── store_lock

So whatever you mount as the /data directory must have a databases sub directory. By default, the /data/databases directory contains a database named graph.db. It could be called anything (your seem to be called epe.graphdb?), in which case one must edit the configuration option dbms.active_database to match the desired name. And to do that in docker, you must mount a /conf volume with a configuration file. (just call it graph.db to make it easy for yourself)

@alexjajones
Copy link
Author

alexjajones commented Nov 14, 2016

Thanks for the quick and detailed reply!

So I have two neo4j data sets on my machine, default.graphdb and epe.graphdb thus the funny names.

This is the top level directory structure of the one I'm trying to include in the neo4j container (epe.graphdb):

epe.graphdb
├── certificates/
├── data/
├── databases/
├── dbms/
├── index/
├── logs/
├── neostore
├── neostore.counts.db.a
├── neostore.counts.db.b
├── neostore.id
├── neostore.labeltokenstore.db
├── neostore.labeltokenstore.db.id
├── neostore.labeltokenstore.db.names
├── neostore.labeltokenstore.db.names.id
├── neostore.nodestore.db
├── neostore.nodestore.db.id
├── neostore.nodestore.db.labels
├── neostore.nodestore.db.labels.id
├── neostore.propertystore.db
├── neostore.propertystore.db.arrays
├── neostore.propertystore.db.arrays.id
├── neostore.propertystore.db.id
├── neostore.propertystore.db.index
├── neostore.propertystore.db.index.id
├── neostore.propertystore.db.index.keys
├── neostore.propertystore.db.index.keys.id
├── neostore.propertystore.db.strings
├── neostore.propertystore.db.strings.id
├── neostore.relationshipgroupstore.db
├── neostore.relationshipgroupstore.db.id
├── neostore.relationshipstore.db
├── neostore.relationshipstore.db.id
├── neostore.relationshiptypestore.db
├── neostore.relationshiptypestore.db.id
├── neostore.relationshiptypestore.db.names
├── neostore.relationshiptypestore.db.names.id
├── neostore.schemastore.db
├── neostore.schemastore.db.id
├── neostore.transaction.db.72
├── neostore.transaction.db.73
├── schema
└── store_lock

When looking at the structure of epe.graphdb, the /data directory seems to be more complicated than the one you described (limited to three levels deep for readability):

epe.graphdb/data/
├── databases
│   ├── databases
│   │   └── graph.db
│   ├── dbms
│   │   └── auth
│   └── graph.db
│       ├── databases
│       ├── dbms
│       ├── index
│       ├── neostore
│       ├── neostore.counts.db.a
│       ├── neostore.id
│       ├── neostore.labeltokenstore.db
│       ├── neostore.labeltokenstore.db.id
│       ├── neostore.labeltokenstore.db.names
│       ├── neostore.labeltokenstore.db.names.id
│       ├── neostore.nodestore.db
│       ├── neostore.nodestore.db.id
│       ├── neostore.nodestore.db.labels
│       ├── neostore.nodestore.db.labels.id
│       ├── neostore.propertystore.db
│       ├── neostore.propertystore.db.arrays
│       ├── neostore.propertystore.db.arrays.id
│       ├── neostore.propertystore.db.id
│       ├── neostore.propertystore.db.index
│       ├── neostore.propertystore.db.index.id
│       ├── neostore.propertystore.db.index.keys
│       ├── neostore.propertystore.db.index.keys.id
│       ├── neostore.propertystore.db.strings
│       ├── neostore.propertystore.db.strings.id
│       ├── neostore.relationshipgroupstore.db
│       ├── neostore.relationshipgroupstore.db.id
│       ├── neostore.relationshipstore.db
│       ├── neostore.relationshipstore.db.id
│       ├── neostore.relationshiptypestore.db
│       ├── neostore.relationshiptypestore.db.id
│       ├── neostore.relationshiptypestore.db.names
│       ├── neostore.relationshiptypestore.db.names.id
│       ├── neostore.schemastore.db
│       ├── neostore.schemastore.db.id
│       ├── neostore.transaction.db.0
│       ├── schema
│       └── store_lock
└── dbms
    └── auth

So my question would be, should I be referencing epe.graphdb/data/ or epe.graphdb/data/databases or something completely different?

Hope that makes sense,

Thanks again!

@spacecowboy
Copy link
Contributor

You have some nested databases there due to mounting the wrong
directories in docker (which then created new database subdirectories
when it concluded the directories did not contain existing databases).

If you want to mount epe.graphdb, you need to place it in a
directory structure which maps to what neo4j expects.

NOTE: The directory structure changed in Neo4j 3.0 and that is
what I am describing here and assuming that you are using.

Easy and safe way

Currently you have:

/User/testuser/Documents/Neo4j/epe.graphdb

The easiest way to mount that in docker is to do:

mkdir -p /User/testuser/Documents/Neo4j/databases
mv /User/testuser/Documents/Neo4j/epe.graphdb /User/testuser/Documents/Neo4j/databases/graph.db

And then you'd specify this in your compose file:

volumes:
    - /User/testuser/Documents/Neo4j:/data

Note that I renamed the database to avoid having to specify a full
configuration file.

Advanced and dangerous way

There is nothing magic going on here, so you can in fact mount your
desired database directly as graph.db inside the docker
container. We don't really want you to do this because it might change
at any time, but it might help you better understand how the mounting
works.

Your compose file just needs to specify:

volumes:
    - /User/testuser/Documents/Neo4j/epe.graphdb:/data/databases/graph.db

This mounts your local database named epe.graphdb as database
graphdb inside the container. You can do the same for hp.graphdb.

@alexjajones
Copy link
Author

Fantastic!! That worked like a charm, I'm very grateful for your help 👍 If we ever cross paths, coffees/beers are on me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants