Introduction
Docker can be downloaded for MacOS, Windows, and Linux operating systems from https://www.docker.com/get-started. There is an official Neo4j image on DockerHub that provides a standard, ready-to-run package of Neo4j. From the DockerHub repo, it is possible to run Community Edition or Enterprise Edition with a variety of Neo4j versions.
Neo4j editions
Tags are available for both Community Edition and Enterprise Edition.
Version-specific Enterprise Edition tags have an -enterprise suffix, for example: neo4j:4.0.12-enterprise.
Community Edition tags have no suffix, for example neo4j:4.0.12.
The latest Neo4j Enterprise Edition release is available as neo4j:enterprise.
All supported tags can be found at https://hub.docker.com/_/neo4j/?tab=tags.
Neo4j Enterprise Edition license
In order to use Neo4j Enterprise Edition, you must accept the license agreement.
© Network Engine for Objects in Lund AB. 2021. All Rights Reserved. Use of this Software without a proper commercial license with Neo4j, Inc. or its affiliates is prohibited.
Email inquiries can be directed to: [email protected]
More information is also available at: https://neo4j.com/licensing/
To accept the license agreement, set the environment variable NEO4J_ACCEPT_LICENSE_AGREEMENT=yes:
--env NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
Using the Neo4j Docker image
A Neo4j container can be started using the following command:
docker run \
--restart always \
--publish=7474:7474 --publish=7687:7687 \
--volume=$HOME/neo4j/data:/data \
neo4j:4.0
However, there are several options with the docker run command.
This table lists some of the options available:
| Option | Description | Example |
|---|---|---|
|
Name your container to avoid generic ID |
|
|
Specify which container port to expose |
|
|
Detach container to run in background |
|
|
Bind mount a volume |
|
|
Set config as environment variables for Neo4j database |
|
|
Control whether Neo4j containers start automatically when they exit, or when Docker restarts. |
|
|
Output full list of |
|
|
The If you no longer want to have the container auto-start on machine boot, you can disable this setting using the flag
For more information on Docker restart policies, see The official Docker documentation. |
Offline installation of Neo4j Docker image
Docker provides the docker save command for downloading an image into a .tar package so that it can be used offline, or transferred to a machine without internet access.
This is an example command to save the neo4j:4.0 image to a .tar file:
docker save -o neo4j-4.0.tar neo4j:4.0
To load a docker image from a .tar file created by docker save, use the docker load command.
For example:
docker load --input neo4j-4.0.tar
For complete instructions on using the docker save and docker load commands, refer to:
Using NEO4J_AUTH to set an initial password
By default, Neo4j requires authentication and prompts you to login with a username/password of neo4j/neo4j at the first connection.
You are then prompted to set a new password.
For more information about setting the initial password for Neo4j, see
Set an initial password.
When using Neo4j in a Docker container, you can set the initial password for the container directly by specifying the NEO4J_AUTH in your run directive:
--env NEO4J_AUTH=neo4j/your_password
Alternatively, you can disable authentication by specifying NEO4J_AUTH to none:
--env NEO4J_AUTH=none
|
There is currently no way to change the initial username |
If you have mounted a /data volume containing an existing database, setting NEO4J_AUTH will have no effect.
The Neo4j Docker service will start, but to log in you will need a username and password already associated with the database.
Running Neo4j as a non-root user
For security reasons, Neo4j runs as the neo4j user inside the container.
You can specify which user to run as by invoking docker with the --user argument.
For example, the following runs Neo4j as your current user:
docker run \
--publish=7474:7474 --publish=7687:7687 \
--volume=$HOME/neo4j/data:/data \
--volume=$HOME/neo4j/logs:/logs \
--user="$(id -u):$(id -g)" \
neo4j:4.0
| The folders that you want to mount must exist before starting Docker, otherwise Neo4j will fail to start due to permissions errors. |