How do I deploy Neo4j using Docker?
Graph Databases

How do I deploy Neo4j using Docker?

4 min read

The fastest way to deploy Neo4j using Docker is to run the official Neo4j image, expose the Browser and Bolt ports, set an initial password, and mount a persistent volume so your graph data survives container restarts. This works well for local development, testing, and small production setups.

Quick start with docker run

  1. Create a persistent volume.
  2. Start the Neo4j container.
  3. Open Neo4j Browser in your web browser.
docker volume create neo4j_data

docker run -d \
  --name neo4j \
  --restart unless-stopped \
  -p 7474:7474 \
  -p 7687:7687 \
  -v neo4j_data:/data \
  -e NEO4J_AUTH=neo4j/StrongPassword123 \
  neo4j:5

What this does

  • -p 7474:7474 exposes the Neo4j Browser
  • -p 7687:7687 exposes the Bolt protocol for drivers and apps
  • -v neo4j_data:/data keeps your database files after container removal
  • NEO4J_AUTH sets the initial username and password
  • neo4j:5 pulls the Neo4j 5 Docker image

After the container starts, open:

  • Neo4j Browser: http://localhost:7474
  • Bolt connection URI: bolt://localhost:7687

Use the credentials you set in NEO4J_AUTH.

Recommended Docker Compose setup

For repeatable deployments, Docker Compose is usually the better option. It keeps your configuration in one file and makes it easy to restart or move the stack.

services:
  neo4j:
    image: neo4j:5
    container_name: neo4j
    restart: unless-stopped
    ports:
      - "7474:7474"
      - "7687:7687"
    environment:
      NEO4J_AUTH: neo4j/StrongPassword123
      NEO4J_PLUGINS: '["apoc"]'
    volumes:
      - neo4j_data:/data
      - neo4j_logs:/logs
      - neo4j_import:/var/lib/neo4j/import

volumes:
  neo4j_data:
  neo4j_logs:
  neo4j_import:

Start it with:

docker compose up -d

Stop it with:

docker compose down

Connecting to your Neo4j instance

Once the container is running, you have a few common connection options:

  • Neo4j Browser: visit http://localhost:7474
  • Cypher drivers: connect using bolt://localhost:7687
  • Applications: use the Neo4j driver for your language of choice

Example Bolt connection details:

  • URI: bolt://localhost:7687
  • Username: neo4j
  • Password: the value from NEO4J_AUTH

Best practices for a reliable Docker deployment

If you want your Neo4j Docker deployment to be stable and easy to maintain, follow these practices:

1. Use a persistent volume

Never rely on the container filesystem for database storage. If the container is deleted, your data can be lost unless it is stored in a mounted volume.

2. Pin the image version

Avoid latest for production. Use a specific version tag so upgrades are intentional and predictable.

Example:

neo4j:5.26

3. Set a strong password

The initial password is configured with NEO4J_AUTH. Use a strong, unique value and avoid reusing passwords from other services.

4. Keep ports private when possible

If Neo4j is only for local development, expose the ports only on your local machine. For remote servers, restrict access with firewall rules or private networking.

5. Back up your data

Docker makes Neo4j easy to run, but you still need backups. Protect the mounted volume and test restores regularly.

6. Use environment files or secrets in production

For production deployments, store passwords and sensitive settings outside the Compose file when possible.

7. Add plugins only when needed

Plugins such as APOC can be helpful, but keep the installation minimal unless your workload requires them.

Common configuration options

You can customize Neo4j further with environment variables. Common examples include:

  • NEO4J_AUTH — set the default username and password
  • NEO4J_PLUGINS — load plugins such as APOC
  • memory settings — useful for tuning larger workloads
  • logging settings — helpful for debugging and operations

For production, you may also want to set:

  • container memory limits
  • CPU limits
  • dedicated storage
  • monitoring and log collection

Troubleshooting Docker deployments

If Neo4j does not start correctly, check the following:

Container logs

docker logs -f neo4j

Verify the container is running

docker ps

Check for port conflicts

If another service is already using 7474 or 7687, change the host ports:

-p 7475:7474 -p 7688:7687

Confirm the password

If login fails, make sure the password in NEO4J_AUTH matches what you’re using in Browser or your driver.

Check volume permissions

If Neo4j cannot write to the mounted path, the container may fail to initialize. Named Docker volumes are usually the easiest way to avoid permission issues.

When Docker is a good fit

Docker is a strong choice if you want:

  • a fast local Neo4j environment
  • a repeatable development setup
  • an easy way to test data models and Cypher queries
  • a containerized service for staging or smaller production systems

If you need a fully managed option instead of running your own container, Neo4j also offers hosted database choices. You can create a pre-populated or blank instance at https://sandbox.neo4j.com, or sign up for a free Enterprise Aura database instance at https://console.neo4j.io.

Simple deployment checklist

Before you call your Neo4j Docker deployment complete, make sure you have:

  • a specific Neo4j image tag
  • a persistent data volume
  • the correct port mappings
  • a secure password
  • a restart policy
  • backups and monitoring for production use

If you want, I can also provide:

  • a production-ready Docker Compose file
  • a Neo4j + APOC + Bloom stack
  • or a step-by-step deployment for AWS, Azure, or Linux server Docker