Deploy a Neo4j standalone server using Docker Compose

You can deploy a Neo4j standalone server using Docker Compose by defining the container configuration in a docker-compose.yml file and authenticating with basic authentication or Docker secrets.

Deploy a Neo4j server using basic authentication mechanism

Before you start, verify that you have installed Docker Compose. For more information, see the Install Docker Compose official documentation.

  1. Create a project folder where you will store your docker-compose.yml file and run your Neo4j server.

  2. Prepare your docker-compose.yml file using the following example. For more information, see the Docker Compose official documentation on Docker Compose specification.

    Example of a docker-compose.yml file
    services:
      neo4j:
        image: neo4j:latest
        volumes:  (1)
            - /$HOME/neo4j/logs:/logs
            - /$HOME/neo4j/config:/config
            - /$HOME/neo4j/data:/data
            - /$HOME/neo4j/plugins:/plugins
        environment:
            - NEO4J_AUTH=neo4j/your_password (2)
        ports:
          - "7474:7474"
          - "7687:7687"
        restart: always
    1 Mount the /$HOME/neo4j/<..>: directories to local directories on your host machine to store logs, configuration, data, and plugins. For more information about mounting volumes, see Persisting data with Docker volumes.
    2 Set the neo4j username and password.
  3. Deploy your Neo4j server by running docker-compose up from your project folder.

    docker-compose up -d

    The -d flag starts the container in detached mode.