README.mdā¢7.47 kB
*NOTE:* Supported images are available in the [official image library](https://hub.docker.com/_/neo4j/) on Docker Hub.
Please use those in production.
# Neo4j Docker Image Build and Run Guide
## Prerequisites
- **Docker Desktop** installed and running
- **Git** (for Git Bash on Windows)
- **Make** (optional, for convenience commands)
- **Internet connection** (to download Neo4j source tarballs)
## Quick Start
### 1. Building the Image
#### On Windows (PowerShell)
```powershell
# Navigate to the docker-neo4j directory
cd docker-neo4j
# Build Neo4j 5.9.0 Community Edition on Debian
& "C:\Program Files\Git\bin\bash.exe" ./build-docker-image.sh 5.9.0 community debian
# Build Neo4j 4.4.30 Enterprise Edition on Red Hat UBI9
& "C:\Program Files\Git\bin\bash.exe" ./build-docker-image.sh 4.4.30 enterprise ubi9
```
#### On Linux/Mac
```bash
# Navigate to the docker-neo4j directory
cd docker-neo4j
# Build Neo4j 5.9.0 Community Edition on Debian
./build-docker-image.sh 5.9.0 community debian
# Build Neo4j 4.4.30 Enterprise Edition on Red Hat UBI9
./build-docker-image.sh 4.4.30 enterprise ubi9
```
#### Using Make (Linux/Mac)
```bash
# Build and tag Neo4j 5.9.0 Community Edition
NEO4JVERSION=5.9.0 make tag-debian-community
# Build and tag Neo4j 4.4.30 Enterprise Edition
NEO4JVERSION=4.4.30 make tag-ubi9-enterprise
```
### 2. Running the Container
#### Basic Usage
```bash
# Run Neo4j Community Edition
docker run -d --name neo4j-container \
-p 7474:7474 -p 7687:7687 \
-v neo4j-data:/data \
-v neo4j-logs:/logs \
-e NEO4J_AUTH=neo4j/your-password \
neo4jtest:TAG_ID
# Run Neo4j Enterprise Edition
docker run -d --name neo4j-enterprise \
-p 7474:7474 -p 7687:7687 \
-v neo4j-data:/data \
-v neo4j-logs:/logs \
-e NEO4J_AUTH=neo4j/your-password \
-e NEO4J_ACCEPT_LICENSE_AGREEMENT=yes \
neo4jtest:TAG_ID
```
#### With Custom Configuration
```bash
docker run -d --name neo4j-container \
-p 7474:7474 -p 7687:7687 \
-v neo4j-data:/data \
-v neo4j-logs:/logs \
-v neo4j-conf:/conf \
-e NEO4J_AUTH=neo4j/your-password \
-e NEO4J_server_memory_heap_initial__size=1G \
-e NEO4J_server_memory_heap_max__size=2G \
neo4jtest:TAG_ID
```
### 3. Accessing Neo4j
#### Neo4j Browser (Web Interface)
Open your browser and go to: **http://localhost:7474/**
Login with:
- **Username**: `neo4j`
- **Password**: `your-password` (as set in NEO4J_AUTH)
#### Programmatic Access
- **Bolt Protocol**: `bolt://localhost:7687`
- **HTTP API**: `http://localhost:7474/`
## Build Options
### Supported Versions
- **Neo4j 5.x**: Latest features (recommended)
- **Neo4j 4.4.x**: LTS support
- **Neo4j 4.0-4.3**: Legacy support
### Supported Editions
- **Community**: Free, open-source edition
- **Enterprise**: Commercial edition with advanced features
### Supported Base OS
- **debian**: Debian bullseye-slim (recommended)
- **ubi9**: Red Hat Universal Base Image 9
- **ubi8**: Red Hat Universal Base Image 8 (deprecated)
## Common Issues and Solutions
### Windows Line Ending Issues
If you get errors like `$'\r': command not found`, convert scripts to Unix line endings:
```bash
# Using Git Bash on Windows
dos2unix docker-image-src/common/utilities.sh
dos2unix docker-image-src/5/coredb/docker-entrypoint.sh
dos2unix docker-image-src/5/coredb/neo4j-admin-report.sh
```
### SHA Command Issues
The build script uses `shasum` which may not be available on all systems. The script has been updated to use `sha256sum` as an alternative.
### Download Issues
If the build fails to download the Neo4j tarball, you can manually download it:
```bash
# Download manually
curl -L -o in/neo4j-community-5.9.0-unix.tar.gz https://dist.neo4j.org/neo4j-community-5.9.0-unix.tar.gz
# Then run the build
./build-docker-image.sh 5.9.0 community debian
```
## Container Management
### Check Container Status
```bash
docker ps | grep neo4j
```
### View Logs
```bash
docker logs neo4j-container
```
### Stop/Start Container
```bash
docker stop neo4j-container
docker start neo4j-container
```
### Remove Container (data persists in volumes)
```bash
docker rm neo4j-container
```
## Data Persistence
Neo4j data is stored in Docker volumes:
- **Database data**: `neo4j-data` volume
- **Logs**: `neo4j-logs` volume
- **Configuration**: `neo4j-conf` volume (optional)
To backup data:
```bash
docker run --rm -v neo4j-data:/data -v $(pwd):/backup ubuntu tar czf /backup/neo4j-backup.tar.gz /data
```
## Environment Variables
Common environment variables for configuration:
- `NEO4J_AUTH=neo4j/password` - Set authentication
- `NEO4J_AUTH=none` - Disable authentication (not recommended)
- `NEO4J_ACCEPT_LICENSE_AGREEMENT=yes` - Accept enterprise license
- `NEO4J_server_memory_heap_initial__size=1G` - Set initial heap size
- `NEO4J_server_memory_heap_max__size=2G` - Set maximum heap size
## Using the Built Images
After building, you can tag your images for easier management:
```bash
# Tag the built images
docker tag neo4jtest:TAG_ID neo4j:5.9.0-community-debian
docker tag neo4jadmintest:TAG_ID neo4j-admin:5.9.0-community-debian
# Use the tagged images
docker run -d --name neo4j-container \
-p 7474:7474 -p 7687:7687 \
-v neo4j-data:/data \
-e NEO4J_AUTH=neo4j/password \
neo4j:5.9.0-community-debian
```
## Complete Example
Here's a complete example from building to running Neo4j:
```bash
# 1. Build the image
& "C:\Program Files\Git\bin\bash.exe" ./build-docker-image.sh 5.9.0 community debian
# 2. Find the built image ID
docker images | grep neo4jtest
# 3. Run the container
docker run -d --name neo4j-container \
-p 7474:7474 -p 7687:7687 \
-v neo4j-data:/data \
-v neo4j-logs:/logs \
-e NEO4J_AUTH=neo4j/mypassword \
neo4jtest:TAG_ID
# 4. Check if it's running
docker ps | grep neo4j
# 5. View startup logs
docker logs neo4j-container
# 6. Access Neo4j Browser at http://localhost:7474
# Login with: neo4j/mypassword
```
## Testing Your Build
After building and running, you can test your Neo4j instance:
```bash
# Test with cypher-shell (if available)
docker exec -it neo4j-container cypher-shell -u neo4j -p mypassword
# Or test with curl
curl -u neo4j:mypassword -H "Content-Type: application/json" \
-X POST http://localhost:7474/db/data/transaction/commit \
-d '{"statements":[{"statement":"CREATE (n:Test {name: \"Hello World\"}) RETURN n"}]}'
```
# Neo4j images for ARM64
From 4.4.0 and onwards, Neo4j images have been available for ARM64 architectures through [Docker Hub](https://hub.docker.com/_/neo4j/).
For earlier versions, we provide unsupported and untested builds of ARM64 Neo4j community edition from 4.0.0 to 4.3.23.
These are unsuitable for production use, but may be useful for experimentation or hobbyists.
They are available on Docker hub at:
https://hub.docker.com/r/neo4j/neo4j-arm64-experimental
The images take the name format `neo4j/neo4j-arm64-experimental:<VERSION>-arm64`.
## Building on ARM64
The build process is the same as on other architectures for Neo4j 4.4.0+:
```bash
# ARM64 build example
./build-docker-image.sh 4.4.30 community debian
```
# Building and Developing the Neo4j Docker Image
See [DEVELOPMENT.md](DEVELOPMENT.md)
# Getting support and contributing
For bug reports and feature requests, please create issues and pull requests against this Github repository.
If you need guidance with using Neo4j you can ask questions here: https://community.neo4j.com/