Install Neo4j Inside Docker Container in Linux

Install Neo4j Inside Docker Container in Linux

Neo4j is a graph database that stores nodes and relationships instead of tables, or documents. Neo4j is accessible using the Cypher query language through HTTP endpoint or binary Bolt protocol.

This tutorial explains how to install Neo4j inside a Docker container in the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install Neo4j

  • Host network

Run the following command to create a container for Neo4j that uses host network:

docker run -d --name=neo4j --restart=always --network=host \
    -v /opt/neo4j/data:/data \
    -v /opt/neo4j/logs:/logs \
    neo4j
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, Neo4j service is listening on two ports, 7474 for HTTP and 7687 for Bolt. Both ports can be changed with -p option.

docker network create app-net
docker run -d --name=neo4j --restart=always --network=app-net \
    -p 8080:7474 -p 8081:7687 \
    -v /opt/neo4j/data:/data \
    -v /opt/neo4j/logs:/logs \
    neo4j

Testing Neo4j

Open a web browser and go to http://<IP_ADDRESS>:7474, where <IP_ADDRESS> is the IP address of the system. Log in to the browser UI with the neo4j username and neo4j password.

Install Neo4j Inside Docker Container in Linux

Uninstall Neo4j

To completely remove Neo4j, remove its container:

docker rm --force neo4j

Remove Neo4j image:

docker rmi neo4j

You can also remove Neo4j data and logs:

sudo rm -rf /opt/neo4j

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.