The Neo4j-Docker Image You’ve Been Asking For: Now in Beta

Head of Product Innovation & Developer Strategy, Neo4j
4 min read


Run it
# interactive with terminal docker run -i -t --rm --name neo4j -v $HOME/neo4j-data:/data -p 8474:7474 neo4j/neo4j # as daemon running in the background docker run -d --name neo4j -v $HOME/neo4j-data:/data -p 8474:7474 neo4j/neo4j
store-files
, logs
, auth
etc. resides on your host system outside of the image. It can be just any empty directory or a (copy of a) data directory of a (not-running) Neo4j-server. You can mount it with the -v
option.
Then, access https://localhost:8474 (or whatever port you exposed) on your machine to use Neo4j.
On OSX you have to use boot2docker and make the bootdocker environment variables available in your current shell session to have Docker connect correctly to the virtual machine. For accessing Neo4j, you have to use the IP of the $DOCKERHOST environment variable. |
2.2.3
: Neo4j Community 2.2.3 Stable Version2.3-M02
: Neo4j Community 2.3-M02 Milestone Previewlatest
: latest stable version (now 2.2.3) (master)
Implementation
The implementation is pretty straightforward, you can follow it in the Dockerfile on GitHub:- based on ubuntu + java8 image
- download and extract the correct Neo4j community version to
/var/lib/neo4j
- mount
/data
directory within volume - update some configuration values (enable shell, set max tx-log-file size, data directory, fix RRD issue)
- expose ports
7474
and7473
for http(s) and1337
and1099
for neo4j-shell - add and run a start script named
neo4j.sh
- the start script sets some runtime configuration parameters
- links the
/data
directory to/var/lib/neo4j/data
- optionally disables
auth
- starts Neo4j in console mode
Building the Image
1. Build & Run:git clone https://github.com/neo4j-contrib/docker-neo4j
cd docker-neo4j
docker build .
# note the resulting image-id
# name your image with `--name`
# run the image, `-i -t` stand for interactive and terminal so you can stop the server with ctrl-c
# `--rm` deletes the image instance after it has stopped
# pass in the path to an existing neo4j `data` directory or just an empty directory
# `-d` would run it in detached daemon mode, which is the opposite of `-i -t`
# docker run -i -t --rm --name neo4j -v </path/to/neo4j/data-dir>:/data -p <external port>:7474 <image-id>
# for example:
docker run -i -t --rm --name neo4j -v $HOME/neo4j-data:/data -p 8474:7474 <image-id>
`https://localhost:8474`
$DOCKERHOST
instead.
Authentication
Please note that Neo4j 2.2.x requires authentication. You have to login withneo4j/neo4j
at the first connection and set a new password. Or use the appropriate [REST endpoint] to configure the initial password. The auth
credentials are stored in the /data/dbms/auth
file, which will reside in the data directory on your host filesystem.
You can also access the Neo4j log-files in data/log
and data/graph.db/messages.log
If you set an environment variable NEO4J_NO_AUTH
to a non-empty value, Neo4j’s authentication will be disabled when the Neo4j server in the image is started.
Have fun with the Docker Image and please provide us feedback, via GitHub issues, Twitter or by dropping us an email.
References
- Neo4j on Docker Hub
- Docker GitHub Repository
- Neo4j with Docker Developer Pages