Docker and Neo4j for Developers Who Can’t Read Good and Want to Do Other Stuff Good Too
TL;DR
If you don’t feel like reading and just want a script to spin up a Docker instance with Neo4j that has the right ports open, as well as logs and data persisted outside of the container:
docker run \
-p 7474:7474 \
-p 7687:7687 \
-p 7473:7473 \
-v $HOME/neo4j/data:/data \
-v $HOME/neo4j/logs:/logs \
-v $HOME/neo4j/import:/var/lib/neo4j/import \
-v $HOME/neo4j/conf/:/conf/ \
neo4j:latest
Important Resources for Further Reading:
A step-by-step guide to Neo4j and Docker:
I’ll admit it— I’m late to the party. Really late to the party. For the past few years+, every conference talk I’ve seen has been some version of: “Web-scale map-reduced machine-learning with artificially intelligent sentiment aware recommendations on Docker in the cloud.” Naturally, because it was new and trendy— I assumed it was stupid and would die soon. I also thought Uber was a bad idea. So, I’m probably not the best litmus for these things.
It’s now 2016 and containers are here to stay. They’re probably going to continue growing in popularity, especially as more and more enterprises deploy their infrastructure in the cloud. This guide is for all the other curmudgeons out there.
What is a Container and Why Do I Care?
A container is basically (but not actually) a very flexible, very lightweight, easier-to-manage virtual machine. In the olden days, when Cobalt developers roamed the earth— one application, one (physical server) server. If you were a hardware salesperson, times were good. If you were a developer, well…I’m sorry.
One Server, One Application.
Then came the hypervisor, which allowed a physical server to create virtual “computers” within itself. Wherein a server may be running several different operating systems, all with different libraries, and applications. Each VM (Virtual Machine), functions as an isolated partition within the host computer, made up of its own resources (disk, memory, etc.) as well as a guest operating system. VMs made cloud hosting possible. Users can now easily provision a VM on a large communally shared machine.
Virtualized Hardware.
A container, by contrast, doesn’t require a guest operating system— a subtle but important distinction. By hooking into the host operating system’s kernel, tools like Docker are able to allow many applications to run in isolation, without the additional bulk of dozens of operating systems that aren’t actually contributing much. Docker Engine and it’s affiliated tools, allow for simple container management.
Dockerized Containers, Many Apps, One Server.
Step by Step Guide to Setting Up Neo4j on Docker
Step 1: Install Docker
If you haven’t already, go and download Docker. Select the appropriate version based on your operating system, Docker has great documentation for this part of the process. I won’t redouble their efforts.
Step 2: Start Docker
If you’re on OS X, navigate (or search) to the Docker Engine application, make sure it’s running. Open your terminal.
Step 3: Start Neo4j
One of the things that makes Docker so great is how easy is it to pull and run different images of containers. A Docker Image is an application blueprint. You can make these yourself or pull them from the Docker equivalent to the app store called “Docker Hub”.
To start a container, we’ll use the
run
command. The syntax for this is:docker run [options] [ image ]:[ tag ] [command] [ arguments ]
For example:
docker run neo4j:latest echo “i got that graphy feeling"
The above is telling docker to run the neo4j version that has been tagged “latest” and then to echo the string “i got that graphy feeling.” The are many different versions of Neo4j on the Docker Hub. For example, the tag: “enterprise” (which will pull the image of the latest version of Neo4j Enterprise) or you can specify the tag version: “3.0.6” or “3.0.6-enterprise.”
Opening your container to the outside world:
If you execute the command above, you may notice that you can’t actually access Neo4j or the Neo4j Browser.
We need to publish some ports using the “-p” option.
docker run \
-p 7474:7474 \
-p 7687:7687 \
-p 7473:7473 \
neo4j:3.0.6-enterprise
What we’re doing above is mapping ports on our host machine to ports within our container. The three ports for remote access are by default:
7474
for HTTP.7473
for HTTPS.7687
for Bolt.
Hi, This was very useful update. Thanks
very informative. thanks for sharing.
You win simply by the title of your post 🙂 Thanks for sharing !