Run neo4j-shell inside docker

‹ Rebase all local branches in git | Exporting a graph from neo4j and importing it into gephi ›

To start the neo4j docker image with neo4j-shell enabled, run:

docker run \
--publish=7474:7474 --publish=7687:7687 \
--volume=$HOME/neo4j/data:/data \
neo4j sh -c "cd /var/lib/neo4j; sed -i -e 's/#dbms.shell/dbms.shell/g' conf/neo4j.conf; curl http://dist.neo4j.org/jexp/shell/neo4j-shell-tools_3.0.1.zip -o neo4j-shell-tools.zip; unzip -o neo4j-shell-tools.zip -d lib; /docker-entrypoint.sh neo4j" 

Then you can run neo4j-shell using docker exec like this:

docker exec -i -t `docker ps -f ancestor=neo4j -q` /var/lib/neo4j/bin/neo4j-shell -port 1337

neo4j-shell is deprecated, so you can also run cypher-shell with:

docker exec -i -t `docker ps -f ancestor=neo4j -q` /var/lib/neo4j/bin/cypher-shell -u neo4j -p YOURPASSWORD

To export into graphml

docker exec -i -t `docker ps -f ancestor=neo4j -q` /var/lib/neo4j/bin/neo4j-shell -port 1337 -c "export-graphml -o /tmp/out.graphml"
docker exec `docker ps -f ancestor=neo4j -q` cat /tmp/out.graphml > out.graphml

Subscribe to All Posts - Wesley Tanaka