cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Neo4j Won't Start Within Docker Container

I'm running Neo4j within a docker container. For some reason, it often doesn't want to start. I get the message "Changed password for user 'neo4j'. IMPORTANT: this change will only take effect if performed before the database is started for the first time." Then, after a second, I get "exited with code 1."

I've tried searching for a solution to this issue several times, but no one seems to be having this problem.

Here is my docker-compose configuration for neo4j:

 

 

neo4j_db:
  image: neo4j:4.4.9
  ports:
    - "7474:7474"
    - "7687:7687"
  volumes:
    - ./db/main_db/data:/data
    - ./db/main_db/logs:/logs
  environment:
    - NEO4J_AUTH=neo4j/this-is-a-password
    - NEO4J_dbms_connector_bolt_listen__address=:7687
    - NEO4J_dbms_connector_bolt_advertised__address=:7687
    - NEO4J_dbms_connector_http_listen__address=:7474
    - NEO4J_dbms_connector_http_advertised__address=:7474

 

Please let me know if there's any additional information I can provide.

2 REPLIES 2

I wasn't able to find out why this occurs, but I seem to have mostly solved it by adding a restart: unless-stopped section to my docker-compose file. This causes it to restart if it exits unexpectedly. It still crashes for me, but after it restarts itself it usually works perfectly. My docker-compose.yml file now looks like the following:

neo4j_db:
  image: neo4j:4.4.9
  restart: unless-stopped
  ports:
    - "7474:7474"
    - "7687:7687"
  volumes:
    - ./db/main_db/data:/data
    - ./db/main_db/logs:/logs
  environment:
    - NEO4J_AUTH=neo4j/this-is-a-password
    - NEO4J_dbms_connector_bolt_listen__address=:7687
    - NEO4J_dbms_connector_bolt_advertised__address=:7687
    - NEO4J_dbms_connector_http_listen__address=:7474
    - NEO4J_dbms_connector_http_advertised__address=:7474

One other thing that seemed to help was to change the neo4j version. For example, I tried changing from version "4.4.9" to "4.2", and it started giving me error messages before exiting. I didn't understand what they meant, but they might give you some leads if your issues persist. I'm also not sure why a previous version shows error messages while the latest one doesn't. Maybe there's a bug in version "4.4.x" which prevents this? You can change the version to "4.2" by changing "image: neo4j:4.4.9" to "image: neo4j:4.2".

I don't understand, why you want to create your own docker-image.

Have you tried to just run

docker run neo4j:4.4.9 

?

I don't understand, why you are tying to 'change' (quotes because you don't really change them) the ports in the env section...

I use a script like this, and it works fine for me (a bit abbreviated for clarity):

#!/usr/bin/bash

buildNumber=4.4.4

docker pull neo4j:${buildNumber}

docker run --detach --restart=always \
-p 47473:7473 -p 47474:7474 -p 47687:7687 \
-e NEO4J_dbms_tx__log_rotation_retention__policy=false \
-e NEO4J_dbms_allow__upgrade=true \
-e NEO4J_dbms_memory_heap_initial__size=500M \
-e NEO4J_dbms_memory_heap_max__size=1G \
-e MALLOC_ARENA_MAX=2 \
-e JAVA_TOOL_OPTS=-XX:-UseGCOverheadLimit \
--memory=2g \
-v ${dbRootDir}/data:/data/ \
-v ${dbRootDir}/conf:/conf/ \
-v ${dbRootDir}/logs:/logs/ \
--ulimit=nofile=40000:40000 \
neo4j:${buildNumber}

 HTH