Docker Compose

If you define an application with Docker Compose, you can use that definition to run the application in CI, staging, or production environments. Here you can find docker-compose.yml files necessary to run memgraph-platform, memgraph-mage and memgraph images.

Docker Compose for Memgraph Platform image

The memgraph-platform Docker image contains:

  • Memgraph database - the database that holds your data
  • Memgraph Lab - visual user interface for running queries and visualizing graph data
  • mgconsole - command-line interface for running queries
  • MAGE - graph algorithms and modules library
version: "3"
services:
  memgraph-platform:
    image: "memgraph/memgraph-platform"
    ports:
      - "7687:7687"
      - "3000:3000"
      - "7444:7444"
    volumes:
      - mg_lib:/var/lib/memgraph
      - mg_log:/var/log/memgraph
      - mg_etc:/etc/memgraph
    env_file:
      - /path_to/.env  # Replace this with the actual path to your .env file
    entrypoint: ["/usr/bin/supervisord"]
volumes:
  mg_lib:
  mg_log:
  mg_etc:

and your .env file contains configuration flags you want to set:

MEMGRAPH="--log-level=TRACE"

The port 7687 is used for communication with Memgraph via Bolt protocol. The port 3000 is exposed because Memgraph Lab will be running as a web application on localhost:3000, while the port 7444 is there so that you can see logs from Memgraph inside Memgraph Lab. We specified three useful volumes:

  • mg_lib - directory containing data that enables data persistency
  • mg_log - directory containing log files
  • mg_etc - directory containing the configuration file

The exact location of the local directories depends on your specific setup.

Configuration settings can be changed by setting the value of the MEMGRAPH environment variable. In the above example, you can see how to set --log-level to TRACE. Since Memgraph Platform is not a single service, the process manager supervisord (opens in a new tab) is used as the main running process in the entrypoint. The MAGE library is included in this image, so you can use the available graph algorithms.

Docker Compose for Memgraph MAGE image

The Memgraph MAGE image contains:

  • Memgraph - the database that holds your data
  • MAGE - graph algorithms and modules library
version: "3"
services:
  memgraph-mage:
    image: "memgraph/memgraph-mage"
    volumes:
      - mg_lib:/var/lib/memgraph
      - mg_log:/var/log/memgraph
      - mg_etc:/etc/memgraph
    ports:
      - "7687:7687"
      - "7444:7444"
    command: ["--log-level=TRACE"]
volumes:
  mg_lib:
  mg_log:
  mg_etc:

The port 7687 is used for communication with Memgraph via Bolt protocol, while the port 7444 is there so that you can see logs from Memgraph inside the Memgraph Lab application. We specified three useful volumes:

  • mg_lib - directory containing data that enables data persistency
  • mg_log - directory containing log files
  • mg_etc - directory containing the configuration file

The exact location of the local directories depends on your specific setup.

We recommend using the command option to customize Memgraph's runtime flags instead of setting them through entrypoint. This approach enhances your flexibility and aligns with Docker best practices, allowing you to easily adjust your container's behavior without altering its foundational settings.

In the above example, you can see how to set --log-level to TRACE. Since the MAGE library is included in this image, you can use the available graph algorithms.

Docker Compose for Memgraph image

The Memgraph image contains the database that holds your data.

version: "3"
services:
  memgraph:
    image: "memgraph/memgraph"
    ports:
      - "7687:7687"
      - "7444:7444"
    volumes:
      - mg_lib:/var/lib/memgraph
      - mg_log:/var/log/memgraph
      - mg_etc:/etc/memgraph
    command: ["--log-level=TRACE"]
volumes:
  mg_lib:
  mg_log:
  mg_etc:

The port 7687 is used for communication with Memgraph via Bolt protocol, while the port 7444 is there so that you can see logs from Memgraph inside the Memgraph Lab application. We specified three useful volumes:

  • mg_lib - directory containing data that enables data persistency
  • mg_log - directory containing log files
  • mg_etc - directory containing the configuration file

The exact location of the local directories depends on your specific setup.

We recommend using the command option to customize Memgraph's runtime flags instead of setting them through entrypoint. This approach enhances your flexibility and aligns with Docker best practices, allowing you to easily adjust your container's behavior without altering its foundational settings.

In the above example, you can see how to set --log-level to TRACE. Since this image doesn't have the MAGE library included, you won't be able to use graph algorithms.

Want to see applications built with Memgraph and Docker Compose? Check out Memgraph's Github (opens in a new tab) repositories.