docker.recipes

Neo4j Graph Database

beginner

Neo4j graph database with web browser interface.

Overview

Neo4j is a native graph database that revolutionizes how applications handle connected data by storing information as nodes and relationships rather than traditional tables. Originally developed in 2007 by Neo Technology, Neo4j uses its proprietary Cypher query language to traverse complex relationship patterns with exceptional performance, making queries that would require expensive JOINs in relational databases execute in milliseconds. The database combines ACID compliance with graph-native storage, allowing applications to model real-world connections naturally while maintaining data integrity. This Docker configuration deploys Neo4j with the APOC (Awesome Procedures on Cypher) plugin pre-installed, providing extended functionality for data integration, graph algorithms, and utility procedures. The setup exposes both the HTTP interface for browser-based interaction and the high-performance Bolt protocol for application connectivity. Memory allocation is configurable through environment variables to optimize performance based on dataset size and query complexity. Developers building recommendation systems, fraud detection platforms, or knowledge management applications will find this stack particularly valuable. The inclusion of APOC procedures enables advanced data manipulation and analysis capabilities that extend Neo4j's core functionality, while the containerized deployment ensures consistent behavior across different environments. Organizations dealing with highly connected data - from social networks to supply chain management - can leverage Neo4j's relationship-first approach to uncover insights that traditional databases struggle to reveal.

Key Features

  • Native graph storage engine optimized for relationship traversal
  • Cypher declarative query language for intuitive graph pattern matching
  • APOC plugin providing 450+ procedures for data integration and analysis
  • Neo4j Browser interface for visual query development and result exploration
  • High-performance Bolt protocol for low-latency application connectivity
  • ACID transaction support ensuring data consistency in concurrent operations
  • Configurable JVM heap allocation for workload-specific performance tuning
  • Built-in graph algorithms library for centrality, community detection, and pathfinding

Common Use Cases

  • 1Social network platforms analyzing user connections and content recommendations
  • 2Financial institutions detecting fraud through transaction relationship analysis
  • 3E-commerce sites building real-time product recommendation engines
  • 4Enterprise knowledge graphs connecting disparate data sources and systems
  • 5Identity and access management systems modeling complex permission hierarchies
  • 6Supply chain optimization tracking product flows and vendor relationships
  • 7Bioinformatics research mapping protein interactions and genetic pathways

Prerequisites

  • Minimum 1GB RAM available for Neo4j container (4GB+ recommended for production)
  • Ports 7474 (HTTP) and 7687 (Bolt) available on the host system
  • Docker Engine 20.10+ and Docker Compose V2 for optimal compatibility
  • Basic understanding of graph database concepts (nodes, relationships, properties)
  • Familiarity with Cypher query language syntax for effective database interaction
  • At least 10GB available disk space for database storage and transaction logs

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 neo4j:
3 image: neo4j:latest
4 container_name: neo4j
5 restart: unless-stopped
6 ports:
7 - "${HTTP_PORT:-7474}:7474"
8 - "${BOLT_PORT:-7687}:7687"
9 environment:
10 - NEO4J_AUTH=${NEO4J_USER:-neo4j}/${NEO4J_PASSWORD:-password}
11 - NEO4J_PLUGINS=["apoc"]
12 - NEO4J_dbms_memory_heap_initial__size=${HEAP_INIT:-512m}
13 - NEO4J_dbms_memory_heap_max__size=${HEAP_MAX:-1G}
14 volumes:
15 - neo4j_data:/data
16 - neo4j_logs:/logs
17 - neo4j_plugins:/plugins
18 networks:
19 - neo4j-network
20
21volumes:
22 neo4j_data:
23 neo4j_logs:
24 neo4j_plugins:
25
26networks:
27 neo4j-network:
28 driver: bridge

.env Template

.env
1# Neo4j
2HTTP_PORT=7474
3BOLT_PORT=7687
4NEO4J_USER=neo4j
5NEO4J_PASSWORD=password
6HEAP_INIT=512m
7HEAP_MAX=1G

Usage Notes

  1. 1Browser at http://localhost:7474
  2. 2Bolt protocol at localhost:7687
  3. 3Login with configured credentials
  4. 4APOC plugin included

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 neo4j:
5 image: neo4j:latest
6 container_name: neo4j
7 restart: unless-stopped
8 ports:
9 - "${HTTP_PORT:-7474}:7474"
10 - "${BOLT_PORT:-7687}:7687"
11 environment:
12 - NEO4J_AUTH=${NEO4J_USER:-neo4j}/${NEO4J_PASSWORD:-password}
13 - NEO4J_PLUGINS=["apoc"]
14 - NEO4J_dbms_memory_heap_initial__size=${HEAP_INIT:-512m}
15 - NEO4J_dbms_memory_heap_max__size=${HEAP_MAX:-1G}
16 volumes:
17 - neo4j_data:/data
18 - neo4j_logs:/logs
19 - neo4j_plugins:/plugins
20 networks:
21 - neo4j-network
22
23volumes:
24 neo4j_data:
25 neo4j_logs:
26 neo4j_plugins:
27
28networks:
29 neo4j-network:
30 driver: bridge
31EOF
32
33# 2. Create the .env file
34cat > .env << 'EOF'
35# Neo4j
36HTTP_PORT=7474
37BOLT_PORT=7687
38NEO4J_USER=neo4j
39NEO4J_PASSWORD=password
40HEAP_INIT=512m
41HEAP_MAX=1G
42EOF
43
44# 3. Start the services
45docker compose up -d
46
47# 4. View logs
48docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/neo4j-graph-database/run | bash

Troubleshooting

  • Neo4j fails to start with 'Cannot allocate memory' error: Reduce NEO4J_dbms_memory_heap_max__size value or increase available system memory
  • Browser shows 'ServiceUnavailable' when connecting: Check that Bolt port 7687 is accessible and Neo4j container has finished initialization
  • APOC procedures not available in queries: Verify NEO4J_PLUGINS environment variable includes 'apoc' and container has restarted after configuration change
  • Authentication fails with default credentials: Ensure NEO4J_AUTH format follows 'username/password' pattern and container has been recreated after password change
  • High memory usage with OutOfMemoryError: Adjust heap size settings and consider adding swap space or upgrading system RAM
  • Slow query performance on large datasets: Enable query logging with NEO4J_dbms_logs_query_enabled=true to identify inefficient Cypher patterns

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space