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).