databasedockerneo4jgraph-databases

Neo4j process running in background even when the docker container isn't running


I'm working on my project for which I'm using Neo4j docker image. I pulled the image from here: https://hub.docker.com/_/neo4j. The problem is the neo4j process continues to run even after stopping the container. So when I run docker start neo4j_db, it doesn't start, and when I check the logs, it says:

Neo4j is already running (pid:7).
Run with '--verbose' for a more detailed error message.
Neo4j is already running (pid:7).
Run with '--verbose' for a more detailed error message.

By using docker inspect, I found out that the initial command it runs is tini -g -- /startup/docker-entrypoint.sh neo4j. I want to stop this global neo4j process so that on running docker start neo4j_db, I can use it on the browser at http://localhost:7474.

I'm new to neo4j, so I don't know how to proceed. Any help is much appreciated.

Update: The sequence of steps I took:

 1. docker pull neo4j
 2. docker run --name neo4j_db --publish=7474:7474 --publish=7687:7687 --volume=./neo4j:/neo4j/data -itd neo4j
 3. docker stop neo4j_db # whenever I want to stop the container
 4. docker start neo4j_db # whenever I want to start the container

Also, I don't have any dockerfile yet. Once I've a container, I just start/stop it to use it in future.


Solution

  • As was already said in the comments, it's more normal to kill containers than to stop them. Since neo4j is a database, you want to be extra sure that there aren't any stray containers still running and writing to your data causing data corruption.

    To have your data persist between containers, mount your data folder to /data not /neo4j/data. If you mount it to /data, then neo4j will automatically write everything there and you can use the same data in future containers to continue on where the last one left off.

    For your example that all means you should be doing:

    docker kill neo4j_db
    docker run -itd \
    --name neo4j_db \
    --publish=7474:7474 \
    --publish=7687:7687 \
    --volume=./neo4j:/data \
    neo4j