Skip to main content
Version: Unreleased 🚧

Install Memgraph Platform on Linux with Docker

This article briefly outlines the basic steps necessary to install and run Memgraph on Linux with Docker.
There are two main Docker images that you can install:

  • Memgraph Platform which contains:
    • Memgraph
    • the visual user interface Memgraph Lab
    • the command-line interface mgconsole
    • the graph library MAGE
  • Memgraph base image: contains only Memgraph.
caution

Memgraph Platform is the recommended Docker image. If you insist on using the Memgraph base image, be aware of the differences when interacting with them. We provide code snippets for working with both types of images below.

Prerequisites

Before you proceed with the installation guide, make sure that you have:

info

Memgraph's Docker image was built with Docker version 1.12 and should be compatible with all newer versions.

Memgraph Platform

Installation guide

1. Download and load the Memgraph Platform Docker image with the following command:

 docker pull memgraph/memgraph-platform

2. Create a new tag for the image so it can be called as memgraph instead of memgraph/memgraph-platform:

docker image tag memgraph/memgraph-platform memgraph
Memgraph Platform

The memgraph/memgraph-platform Docker image contains Memgraph, Memgraph Lab and mgconsole. After running the image, mgconsole will open in the terminal while Memgraph Lab is available on http://localhost:3000.

Starting Memgraph Platform

To start Memgraph, use the following command:

docker run -it -p 7687:7687 -p 3000:3000 memgraph/memgraph-platform
Docker Volumes

Docker containers don’t persist data by default (all changes are lost when the container is stopped). You need to use local volumes to store the data permanently, which is why Memgraph is started with the -v flag.

docker run -it -p 7687:7687 -p 3000:3000 -v mg_lib:/var/lib/memgraph memgraph/memgraph-platform

More information on Docker Volumes can be found here.

If successful, you should see a message similar to the following:

mgconsole X.X
Connected to 'memgraph://127.0.0.1:7687'
Type :help for shell usage
Quit the shell by typing Ctrl-D(eof) or :quit
memgraph>

If you want to start Memgraph with different configuration settings, check out the section below. At this point, Memgraph is ready for you to submit Cypher queries.

info

The username and password for connecting to the database are empty by default.

Stopping Memgraph Platform

To stop a Memgraph database instance, run the following command:

docker stop CONTAINER_NAME

You can find the name of the container (CONTAINER_NAME) by running:

docker ps

Configuration

The Memgraph configuration is available in Docker's named volume mg_etc. On Linux systems, it should be in /var/lib/docker/volumes/mg_etc/_data/memgraph.conf. Keep in mind that this way of specifying configuration options is only valid if Memgraph was started using volumes.

When using Docker, you can also specify the configuration options in the docker run command:

docker run -it -p 7687:7687 -p 3000:3000 -e MEMGRAPH="--bolt-port=7687" memgraph/memgraph-platform

To learn about all the configuration options, check out the Reference guide.

Accessing configuration files and logs

If you need to access the Memgraph configuration file or logs, you will need to specify the following volumes when starting Memgraph:

docker run -it -p 7687:7687 -p 3000:3000 -e MEMGRAPH="--bolt-port=7687" \
-v mg_lib:/var/lib/memgraph \
-v mg_log:/var/log/memgraph \
-v mg_etc:/etc/memgraph \
memgraph/memgraph-platform

The volume mg_etc contains the configuration file while the logs will be saved to mg_log. The location of the volume directories depends on your specific setup but can usually be found in /var/lib/docker/volumes/.

Memgraph base image

Installation guide

1. Download the latest Memgraph Docker image from the Download Hub.

2. If you installed Docker correctly, you can import the image using the following command:

docker load -i /path-to/memgraph-<version>-docker.tar.gz

Starting Memgraph

To start Memgraph, use the following command:

docker run -p 7687:7687 memgraph
Docker Volumes

Docker containers don’t persist data by default (all changes are lost when the container is stopped). You need to use local volumes to store the data permanently, which is why Memgraph is started with the -v flag.

docker run -p 7687:7687 -v mg_lib:/var/lib/memgraph memgraph

More information on Docker Volumes can be found here.

If successful, you should see a message similar to the following:

You are running Memgraph vX.X.X
To get started with Memgraph, visit https://memgr.ph/start

If you want to start Memgraph with different configuration settings, check out the section below. At this point, Memgraph is ready for you to submit Cypher queries.

info

The username and password for connecting to the database are empty by default.

Stopping Memgraph

To stop a Memgraph database instance, run the following command:

docker stop CONTAINER_NAME

You can find the name of the container (CONTAINER_NAME) by running:

docker ps

Configuration

The Memgraph configuration is available in Docker's named volume mg_etc. On Linux systems, it should be in /var/lib/docker/volumes/mg_etc/_data/memgraph.conf. Keep in mind that this way of specifying configuration options is only valid if Memgraph was started using volumes.

When using Docker, you can also specify the configuration options in the docker run command:

docker run -p 7687:7687 memgraph --bolt-port=7687

To learn about all the configuration options, check out the Reference guide.

Accessing configuration files and logs

If you need to access the Memgraph configuration file or logs, you will need to specify the following volumes when starting Memgraph:

docker run -p 7687:7687 \
-v mg_lib:/var/lib/memgraph \
-v mg_log:/var/log/memgraph \
-v mg_etc:/etc/memgraph \
memgraph --bolt-port=7687

The volume mg_etc contains the configuration file while the logs will be saved to mg_log. The location of the volume directories depends on your specific setup but can usually be found in /var/lib/docker/volumes/.

Differences between Memgraph Docker images

  • Configuration flags need to be passed inside of environmental variables when working with Memgraph Platform. For example, you can start the Memgraph base image with docker run memgraph --bolt-port=7687, while docker run -e MEMGRAPH="--bolt-port=7687" memgraph/memgraph-platform is the same command for Memgraph Platform.

  • When starting Memgraph Platform, you need to include the -it flag that tells Docker to open an interactive container instance. Otherwise, you won't have access to mgconsole.

  • Because Memgraph Platform includes Memgraph Lab, which is a web application, you need to include -p 3000:3000 in the run command so that Lab becomes accessible on https://localhost:3000.

Where to next?

If you need more information on working with Docker, check out this guide.
To learn how to query the database, take a look at the Querying guide or Memgraph Playground for interactive tutorials.
Visit the Building applications page if you need to connect to the database programmatically.

Getting help

If you run into problems during the installation process, check out our installation troubleshooting guide to see if we have already covered the topic. For more information on the installation process and for additional questions, visit the Getting help page.