Join our Discord Server
Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 570+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 8900+ members and discord server close to 2200+ members. You can follow him on Twitter(@ajeetsraina).

Running Neo4j in a Docker Container in 2 Minutes

3 min read

Neo4j is a popular graph database management system used by enterprises, government agencies, and startups worldwide. According to DB-Engines, Neo4j ranks as the number one graph database, with a popularity score of 55.51%. It is known for its speed, scalability, and flexibility, making it a top choice for applications that require complex data structures and relationships.

Neo4j is the most widely deployed graph data platform in the market, used by 200K+ developers, 800+ commercial customers- with dozens of them deploying graph databases with multi-billion nodes and relationships. Over 800 commercial customers and over 4300 startups use Neo4j. Companies such as eBay, Walmart, Cisco, Citibank, ING, UBS, HP, The National Geographic Society, Airbus, Orange, AT&T, Verizon, DHS, US Army, Microsoft, IBM, Thomson Reuters etc uses Neo4j heavily.

Image1

What problem does it solve?

Neo4j delivers graph technology that has been battle tested for performance and scale ground-up. The high-performance distributed cluster architecture of Neo4j enables customers to run the most challenging OLTP and data science workloads, while preserving ACID compliance and data integrity. With Neo4j, customers get the freedom of choice to deploy in a self-hosted, hybrid, or multi-cloud platform.

What does Neo4j offer?

Neo4j offers several significant competitive advantages, including unparalleled performance and scalability. With Neo4j, queries that take seconds, minutes, or even hours on other databases can run in milliseconds, allowing customers to scale their applications without compromising performance or data integrity. Additionally, Neo4j’s hardware efficiency is unmatched, requiring up to ten times less hardware than other graph databases.

Another advantage of Neo4j is its platform agnosticism. The database can run on-premises, in the cloud, or natively on any cloud platform, giving customers the freedom to deploy their applications anywhere they choose. This enables multi-cloud efficiency, faster time to market, development agility, and greater ROI.

Neo4j’s declarative language, Cypher, also enables greater developer productivity, with ten times less code than SQL. Neo4j boasts the world’s largest community of skilled graph developers, providing access to expertise and enabling projects to deliver more, in less time, with less risk.

The database’s flexible schema allows it to adapt to evolving business needs rapidly and without disruption, delivering more in less time, with less risk. Finally, Neo4j Graph Data Science (GDS) offers the industry’s first Graph ML for enterprise, with 50 algorithms across six categories, a low memory format to compress analytics graphs by 75%, and a highly parallelized and massively scalable architecture. These advantages make Neo4j a top choice for enterprises, government agencies, and startups looking to build faster, more efficient, and more flexible applications.

In this blog, you will see how to run Neo4j on Docker Desktop environment.

Getting Started

Prerequisite

  • Install Docker Desktop
  • Enable File Sharing for volume mount

Image2

Running Neo4j Docker Container

docker run -d --name neo4j -p 7474:7474 -p 7687:7687 -v /Users/ajeetsraina/data/neo4j:/data neo4j
 
docker ps
CONTAINER ID   IMAGE                                       COMMAND                  CREATED         STATUS         PORTS                                                      NAMES
9df055061c6b   neo4j                                       "tini -g -- /startup…"   5 seconds ago   Up 4 seconds   7473/tcp, 0.0.0.0:7474->7474/tcp, 0.0.0.0:7687->7687/tcp   neo4j
 

Open the browser and try to access https://localhost:7474 page.

Image3

Accessing Neo4j with Authentication

docker run -d --name neo4j -e NEO4J_AUTH=neo4j/neo4j -p 7474:7474 -p 7687:7687 -v /Users/ajeetsraina/data/neo4j:/data neo4j
 

If you try to access Neo4j, you might encounter an issue:

docker logs -f ba2
Warning: Folder mounted to "/data/transactions" is not writable from inside container. Changing folder owner to neo4j.
Invalid value for password. The minimum password length is 8 characters.
If Neo4j fails to start, you can:
1) Use a stronger password.
2) Set configuration dbms.security.auth_minimum_password_length to override the minimum password length requirement.
3) Set environment variable NEO4J_dbms_security_auth__minimum__password__length to override the minimum password length requirement.
org.neo4j.commandline.admin.security.exception.InvalidPasswordException: A password must be at least 8 characters.

It seems like there are a few issues that need to be addressed:

  • The folder mounted to “/data/transactions” is not writable from inside the container. To fix this, you can change the owner of the folder to neo4j by running the following command:
sudo chown -R neo4j /data/transactions
  • The password provided for Neo4j is invalid as it does not meet the minimum length requirement of 8 characters. You can either use a stronger password that meets this requirement or set the configuration dbms.security.auth_minimum_password_length to override the minimum password length requirement. To set this configuration, add the following line to your neo4j.conf file:
dbms.security.auth_minimum_password_length=8

Alternatively, you can set the

NEO4J_dbms_security_auth__minimum__password__length ``

environment variable to override the minimum password length requirement. To set this variable, run the following command:



export NEO4J_dbms_security_auth__minimum__password__length=8

Finally, if Neo4j fails to start, you can refer to the above steps to fix the issues or check the Neo4j logs to identify any other errors or warnings that may be causing the problem.



docker run -d --name neo4j -e NEO4J_AUTH=neo4j/neo4j12#456 -p 7475:7474 -p 7688:7687 -v /Users/ajeetsraina/data/neo4j:/data neo4j


% docker ps
CONTAINER ID   IMAGE                                       COMMAND                  CREATED         STATUS         PORTS                                                      NAMES
8ff48a7a83e9   neo4j                                       "tini -g -- /startup…"   5 seconds ago   Up 4 seconds   7474/tcp, 0.0.0.0:7474->7474/tcp, 0.0.0.0:7688->7687/tcp   neo4j

This time, it should work as expected.

Image5

Using Docker Compose



services:

  neo4j:
    image: neo4j:latest
    ports:
      - "7474:7474"
      - "7687:7687"
      - "7473:7473"
    environment:
      - NEO4J_AUTH=neo4j/neo4j/neo4j12#456
    networks:
      - net

networks:
  net:

Using Neo4j Docker Extension

Neo4j is a highly scalable, robust native graph database. It is more suitable for certain big data and analytics applications than row and column databases or free-form JSON document databases for many use cases. A graph database is used to represent relationships.

With the Neo4j Docker Extension, once can setup the Neo4j with just a few commands/clicks.

Getting Started

  • Docker Desktop 4.8+
  • Enable the Extension

Installing Neo4j Docker extension using CLI

Neo4j is now available as Docker extension and can be installed directly using Extension Dashboard


Open Docker Dashboard to see Neo4j Docker Extension already up and running.

 

You can even install it using CLI

docker extension install ajeetraina/neo4j-docker-extension:1.0.0

Connecting to the local database

Use neo4j/neo4j as username/password.

Image15

References

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 570+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 8900+ members and discord server close to 2200+ members. You can follow him on Twitter(@ajeetsraina).
Join our Discord Server
Index