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.

Check the status of Neo4J via Docker?

deemeetree
Graph Buddy

I set up my Neo4J db via Docker and I can access Cypher-Shell fine using

docker exec --interactive --tty <container_id> bin/cypher-shell

However, when I try to check whether Neo4J is running using this command:

docker exec --interactive --tty <container_id> bin/neo4j status

It says Neo4j is not running even though it is.

Is it possible to check the status via Docker somehow?

4 REPLIES 4

intouch_vivek
Graph Steward

Hi

Did you check with

docker ps --filter status=running

deemeetree
Graph Buddy

Yes, of course the container is running, this is not the issue.

The issue is to access neo4j command from a running container.

try

docker exec -it <containername> /bin/bash

or

docker exec -it <containername> /bash

It is possible to check if neo4j is running, I have a script I call wait4bolt_outside (below)
which I use to check if neo4j is online and ready after a bulk load db create.
The next step in the script creates indexes, and other misc cypher (label graph islands),
and those scripts can't run successfully until neo4j is completely online and ready.

wait4bolt_outside

#!/bin/bash

CONTAINER=$1

if [[ -z ${CONTAINER} ]]
  then
     echo "Usage:"
     echo "  wait4bolt_outside docker_container"
     echo "  e.g. wait4bolt_outside neo_ag"
     exit 1
fi

PORT=$(docker exec -t ${CONTAINER} bash -c 'echo $NEO4J_dbms_connector_bolt_advertised__address'
 |cut -d : -f 2)
echo "neo4j bolt is on port ${PORT}"

if [[ -z ${PORT} ]]
  then
     echo "Is ${CONTAINER} running neo4j?  I don't see it..."
     echo 
     echo "Usage:"
     echo "  wait4bolt_outside docker_container"
     echo "  e.g. wait4bolt_outside neo_ag"
     exit 1
fi

echo "wait for neo4j bolt to respond at port ${PORT}"

# this returns before server is ready
#    curl -i http://127.0.0.1:${PORT} 2>&1 | grep -c -e '200 OK' || break 

# try an actual query as test?
docker exec -e NEO4J_USERNAME -e NEO4J_PASSWORD -t ${CONTAINER} \
  bash -c "until echo 'match (n) return count(n);' | bin/cypher-shell -a bolt://localhost:${PORT
}; do echo $? ; sleep 1; done"


echo 'neo4j online!'

I am going to guess that neo4j status does not work because inside docker neo4j is run in the docker startup script /docker-entrypoint.sh instead of as a service?

To take a peek inside the running docker container you can launch shell and then run commands, helpful if developing a command, launching a command through docker exec can be a little tricky (with special characters, and issues with stdin/stdout/stderr) I find it easier to get a command working inside docker at the shell prompt, then attempt to launch it from the host outside the container (separately).

docker exec -it containername bash