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


Hear about the New Neo4j-Docker Image That You’ve Been Waiting and Asking For

In response to your many requests, we’re happy to announce our first semi-official (i.e. beta release) Neo4j-Docker image.

It is semi-official, because it doesn’t yet come with guarantees or official customer support and has not been as battle-tested as the rest of our product packaging. So expect the regular issues you might run into with any beta release.

First of all, I want to thank everyone in our community who already provided great Docker images for Neo4j. We took inspiration from those first attempts when creating our own. Special thanks to Abed Halawi, Kenny Bastani, and Ben Butler-Cole.

We’re also grateful for the feedback that we already got in the discussion with these authors around the requirements and realisation of the image.

We made the recent versions available on Docker-Hub but you can also build it on your own from our GitHub Repository.

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

The data-directory, containing the 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.

There are several tags available:

  • 2.2.3: Neo4j Community 2.2.3 Stable Version
  • 2.3-M02: Neo4j Community 2.3-M02 Milestone Preview
  • latest: latest stable version (now 2.2.3) (master)

These are built from the appropriate branches of the GitHub Repository.

There are also other branches (e.g. for creating Docker images on RedHat Enterprise Linux) which will be the focus of a follow-up article.

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 and 7473 for http(s) and 1337 and 1099 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>

2. Open in browser:

`https://localhost:8474`

On OSX use boot2docker and replace localhost with the IP from $DOCKERHOST instead.

Authentication


Please note that Neo4j 2.2.x requires authentication. You have to login with neo4j/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




Love Docker but want to learn more about Neo4j? Click below to get your free copy of the Learning Neo4j ebook and catch up to speed with the world’s leading graph database.