Cannot edit neo4j.conf

configuration
environment

(Harvey Nguyen) #1

I am installing Neo4j with Docker and I want to modify configuration in neo4j.conf file. However, after restarting container, the values is reset.
Anybody can help me?
image


(Michael Hunger) #2

Did you check the operations manual entry on docker? It's also linked in the intro message to this category.

There you have a section on passing config settings as env parameters.

From those the neo4j.conf is generated inside of the container at startup.

so you can pass any config setting from the outside, the only bit you have to remember is to double the underscore where the setting has an underscore

You also have an option to mount the conf directory but then you have to provide and maintain the full config in there.


(Harvey Nguyen) #3

Thanks for your help!
I used env parameters to create container, but now I want to try edit other configs without recreating container.
I also have tried to mount the conf directory but this folder is empty.
I used docker-compose to create container. Below is my docker-compose file:

version: '3'
services:
  local-env:
    image: neo4j:latest
    network_mode: "bridge"
    ports:
      - "7474:7474"
      - "7473:7473"
      - "7687:7687"
      - "2322:22"
    environment:
      - NEO4J_dbms_security_procedures_unrestricted=apoc.*,algo.*
      - NEO4J_apoc_import_file_enabled=true
      - NEO4J_dbms_shell_enabled=true
      - NEO4J_dbms_memory_pagecache_size=4G
      - NEO4J_dbms_memory_heap_max__size=8G
      - NEO4J_dbms_memory_heap_initial__size=8G
      - NEO4J_dbms_tx__log_rotation_retention__policy=3G size
    volumes:
      - ./plugins:/plugins
      - ./data:/data
      - ./import:/import
      - ./conf:/conf

Thanks again for your help !


(M. David Allen) #4

It's not possible to impact neo4j's configuration inside of the container without creating a new container. This is because inside of the neo4j docker container (right here: https://github.com/neo4j/docker-neo4j/blob/master/src/3.4/docker-entrypoint.sh#L216) -- the container process is just the neo4j binary.

Now, on linux systems, typically the neo4j binary is wrapped in a system service setup, like sysv, so you can do something like systemctl restart neo4j. This is not the case for the docker container, since it's considered good practice to have a container execute exactly one process. A discussion of why that's good docker practice can be found here.

The downside of this is that you can't change your config and restart the database. When this process finishes, your container exits, that's it.

So what are your options?

  1. Neo4j does have some dynamic configuration settings which can be adjusted by cypher code, with no neo4j.conf needed. If these fit for you, that's what I'd recommend.
  2. You can adjust your environment variables, kill the container, and restart. Note that if you manage volume mappings appropriately, you of course won't lose any data.

Unfortunately, editing configs without restarting the container won't work.