How to set Neo4j conf in docker?

2019-08-18 08:26发布

问题:


I used to run Neo4j separately and then my application interacted with it as required. Every time I fresh installed Neo4j, I had to go to /etc/neo4j/neo4j.conf and comment this one line:

dbms.directories.import=/var/lib/neo4j/import

by putting a # in start of it to make things work for me. By default this line wasn't commented.
Anyways, I am moving to docker now, and I want to know how to change that line in docker environment?

Here's my portion of neo4j in docker file.

neo4j:
    container_name: neo4j_container
    restart: always
    image: neo4j:3.5.3
    ports:
      - "7474:7474"
      - "6477:6477"
      - "7687:7687"
    environment:
      - NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
      - NEO4J_dbms_connector_http_listen__address=:7474
      - NEO4J_dbms_connector_https_listen__address=:6477
      - NEO4J_dbms_connector_bolt_listen__address=:7687

The image of Neo4j I am using, as you can see is neo4j:3.5.3.

回答1:

With the official docker image, you can specify a local folder as the neo4j import folder by adding this line to your command : --volume=/home/bsimard/my_project/neo4j/import:/import

As you see here, I'm mouting my local folder /home/bsimard/my_project/neo4j/import to the /import folder of the image, and this /import folder is used by Neo4j inside docker.

You can take a look at the list of the volumes that the docker uses : https://neo4j.com/docs/operations-manual/3.5/docker/introduction/#docker-volumes

And you can also change any configuration of Neo4j just by providing some environment variables on your docker command. See here : https://neo4j.com/docs/operations-manual/3.5/docker/configuration/#docker-environment-variables

Cheers



回答2:

Doing

volumes:
  - /:/var/lib/neo4j/import

Fixed it for me.



标签: docker neo4j