Install Memgraph with Docker
Docker (opens in a new tab) is a service that uses OS-level virtualization to deliver software in packages that are called containers (opens in a new tab).
Memgraph uses Docker because it is:
- Flexible
- Lightweight
- Portable - you can build locally or deploy to the cloud
- Runs on all platforms - Windows, Linux and macOS
- Deploys in Kubernetes
Memgraph bundles the database along with various analytical tools into distinct Docker images.
Available Docker images
All Memgraph Docker images are available at Memgraph's Docker Hub (opens in a new tab). There you will find the exact Docker image tags you can use to install Memgraph with.
The main repositories that contain memgraph
are:
memgraph/memgraph-mage
- includes Memgraph database, command-line interfacemgconsole
andMAGE
graph algorithms library. If tagged with cuGraph, it also includes NVIDIA cuGraph GPU-powered graph algorithms.memgraph/memgraph
- includes Memgraph database and command-line interfacemgconsole
.
There are also two additional standalone images that do not include the Memgraph:
memgraph/lab
- includes a web interface Memgraph Lab that helps you explore the data stored in Memgraph.memgraph/mgconsole
- includes a command-line interfacemgconsole
that allows you to interact with Memgraph from the command line.
To use Memgraph, run
memgraph/memgraph-mage
,
memgraph/memgraph-mage
+
cuGraph
or
memgraph/memgraph
image. To query Memgraph, use the CLI mgconsole. If you prefer a visual user
interface to query Memgraph, run
memgraph/lab
image or download Desktop
application (opens in a new tab) from Memgraph Download
hub and connect to the running Memgraph instance.
Memgraph and Memgraph Lab can be run as a multi-container application - Memgraph Platform. To do that, run the above images as services with Docker Compose.
Run Memgraph MAGE Docker image
Install and run the memgraph-mage
image using the following command:
docker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraph-mage
You can connect to the Memgraph instance using the command-line interface mgconsole by running the following command in a new terminal:
docker exec -it memgraph mgconsole
You can also connect to Memgraph instance using the Memgraph Lab, available for download from Memgraph's Download Hub (opens in a new tab), or using the Memgraph Lab Docker image.
To start using Memgraph in your application, use one of the client libraries and follow their getting started guide.
Run Memgraph MAGE Docker image + cuGraph
Check prerequisites
To be able to run cuGraph analytics, make sure you have compatible infrastructure first. The exact system requirements are available at the NVIDIA RAPIDS site (opens in a new tab), and include an NVIDIA Pascal (or better) GPU and up-to-date CUDA & NVIDIA drivers.
You will also need to install:
- Official NVIDIA driver (opens in a new tab) for your operating system.
- To run on NVIDIA-powered GPUs, RAPIDS requires Docker CE v19.03+ and nvidia-container-toolkit (opens in a new tab).
- Legacy Docker CE v17-18 users requie the nvidia-docker2 package (opens in a new tab).
Install and run Memgraph
Install and run Memgraph using the following command:
docker run --rm --gpus all -p 7687:7687 -p 7444:7444 memgraph/memgraph-mage:1.3-cugraph-22.02-cuda-11.5
Check the latest versions of cuGraph Docker images at Memgraph's Docker
Hub (opens in a new tab), by searching the
memgraph/memgraph-mage
repository with the cugraph
keyword.
You can connect to the Memgraph instance using the command-line interface mgconsole by running the following command in a new terminal:
docker exec -it memgraph mgconsole
You can also connect to Memgraph instance using the Memgraph Lab, available for download from Memgraph's Download Hub (opens in a new tab).
To start using Memgraph in your application, use one of the client libraries and follow their getting started guide.
Run Memgraph Docker image
Install and run the memgraph
image using the following command:
docker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraph
You can connect to the Memgraph instance using the command-line interface mgconsole by running the following command in a new terminal:
docker exec -it memgraph mgconsole
You can also connect to Memgraph instance using the Memgraph Lab, available for download from Memgraph's Download Hub (opens in a new tab).
To start using Memgraph in your application, use one of the client libraries and follow their getting started guide.
Load and run Memgraph Docker image from Memgraph download hub
If you've downloaded the Memgraph Docker image directly from the Memgraph
download hub (opens in a new tab), you'll receive a file named
similar to memgraph-2.20.0-docker.tar.gz
(the exact file name varies based on
the version you've downloaded).
To load this image into Docker, do the following:
Load the image into Docker
Use the docker load
command to load the
image into Docker:
docker load -i memgraph-2.20.0-docker.tar.gz
Run the Memgraph image
After loading the image, you can run it using the docker run
command. Here’s
an example command to start the Memgraph Docker container:
docker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraph:2.18.0
The :2.18.0
part in the docker run
command refers to the tag of the Docker
image. It is important to specify the correct tag corresponding to the version
of Memgraph you have downloaded and loaded.
To find the available tags for your images, you can use the docker images
command. This command lists all Docker images on your system, including their
tags.
Docker allows multiple versions of the same image to coexist, each tagged with a
different version number. If no tag is specified, Docker will default to using
the :latest
tag.
Run Memgraph Lab image
Install and run the lab
image using the following command:
docker run -d -p 3000:3000 --name lab memgraph/lab
Once the container is up you can access Memgraph Lab on localhost:3000 (opens in a new tab).
Issues when connecting to Memgraph Lab to Memgraph
Issues when linking Memgraph Lab with Memgraph can come from the chosen
deployment method and the operating system deployed. The handling of the
QUICK_CONNECT_MG_HOST
environment variable differs based on the operating
system:
-
Mac or Windows: The
host.docker.internal
hostname allows Docker containers to connect to the host machine. Set this as the value forQUICK_CONNECT_MG_HOST
when running Lab on Mac or Windows to enable connection to Memgraph running on the host:docker run -d -p 3000:3000 -e QUICK_CONNECT_MG_HOST=host.docker.internal --name lab memgraph/lab
-
Linux: There's no need to set
QUICK_CONNECT_MG_HOST
as it defaults tolocalhost
, assuming Memgraph is running locally on the host machine.
You can also use the QUICK_CONNECT_MG_PORT
environment variable to specify the
quick connect port number, e.g. - e QUICK_CONNECT_MG_PORT=7688
.
Configuration options
To learn about all the configuration options, check out the configuration settings.
When using Docker, you can specify the configuration options in the docker run
command:
docker run memgraph/memgraph --bolt-port=7687 --log-level=TRACE
Install Memgraph Platform image up to version 2.14
These instructions are listed here as a reference for legacy installations.
Starting with version 2.15, Memgraph Platform transitions to a multi-container application. This upgrade moves from a single Docker image to separate containers for Memgraph+MAGE and Memgraph Lab, utilizing Docker Compose for deployment and management.
For detailed setup instructions and best practices, please refer to the Docker Compose documentation for Memgraph Platform.
Please note that the Memgraph Platform Docker image (opens in a new tab) is no longer being updated.
Install Docker Desktop
Install Docker Desktop (opens in a new tab) by following the instructions available on their site.
Install and run Memgraph
Open a terminal and use the following command:
docker run -p 7687:7687 -p 7444:7444 -p 3000:3000 --name memgraph memgraph/memgraph-platform
After downloading the image, Memgraph will install and if the installation was successful, you should see a message similar to the following:
C:\Users\Vlasta>docker run -p 7687:7687 -p 7444:7444 -p 3000:3000 --name memgraph memgraph/memgraph-platform
2023-08-29 09:02:59,833 INFO Included extra file "/etc/supervisor/programs/lab.conf" during parsing
2023-08-29 09:02:59,834 INFO Included extra file "/etc/supervisor/programs/memgraph.conf" during parsing
2023-08-29 09:02:59,834 INFO Set uid to user 0 succeeded
2023-08-29 09:02:59,842 INFO supervisord started with pid 1
2023-08-29 09:03:00,845 INFO spawned: 'memgraph' with pid 7
2023-08-29 09:03:00,848 INFO spawned: 'lab' with pid 8
You are running Memgraph v2.10.1
To get started with Memgraph, visit https://memgr.ph/start
[2023-08-29 09:03:01.034] [memgraph_log] [warning] Invalid license key string. To use Enterprise features please set it to a valid string using the following query:
SET DATABASE SETTING "enterprise.license" TO "your-license-key"
[2023-08-29 09:03:01.333] [memgraph_log] [warning] No snapshot or WAL file found. For more details, visit https://memgr.ph/durability.
[2023-08-29 09:03:01.333] [memgraph_log] [warning] Replication configuration will NOT be stored. When the server restarts, replication state will be forgotten.
2023-08-29 09:03:02,334 INFO success: memgraph entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-08-29 09:03:02,335 INFO success: lab entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
[2023-08-29 09:03:02.803] INFO: [lab] Lab is running at http://localhost:3000 in platform mode
DGL backend not selected or invalid. Assuming PyTorch for now.
<frozen importlib._bootstrap>:228: RuntimeWarning: scipy._lib.messagestream.MessageStream size changed, may indicate binary incompatibility. Expected 56 from C header, got 64 from PyObject
[2023-08-29 09:03:09.257] [memgraph_log] [error] Unable to load module "/usr/lib/memgraph/query_modules/libmgclient.so"; /usr/lib/memgraph/query_modules/libmgclient.so: undefined symbol: mgp_init_module. For more details, visit https://memgr.ph/modules.
[2023-08-29 09:03:09.542] [memgraph_log] [error] Unable to load module "/usr/lib/memgraph/query_modules/example_cpp.so"; /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /usr/lib/memgraph/query_modules/example_cpp.so). For more details, visit https://memgr.ph/modules.
[2023-08-29 09:03:09.542] [memgraph_log] [warning] Using non-secure Bolt connection (without SSL). For more details, visit https://memgr.ph/ssl.
Memgraph will start listing the logs, and don't worry about the inital errors and warnings as at this point, they are of informative nature.
Connect to the instance
You can connect to the Memgraph instance using the command-line interface mgconsole by running the following command in a new terminal:
docker run -it memgraph/mgconsole:latest
When the mgconsole starts, you can query the database:
docker run -it memgraph/mgconsole:latest
mgconsole 1.4
Connected to 'memgraph://127.0.0.1:7687'
Type :help for shell usage
Quit the shell by typing Ctrl-D(eof) or :quit
memgraph>
You can also connect to Memgraph using the Memgraph Lab web
application available within the
memgraph-platform
Docker image by visiting localhost:3000
.
To start using Memgraph in your application, use one of the client libraries and follow their getting started guide.
Running individual tools from Memgraph Platform image
You can run only the Memgraph database instance from the Memgraph Platform image using the following command:
docker run -p 7687:7687 memgraph/memgraph-platform -c /etc/supervisor/supervisord-memgraph-only.conf
You can run only mgconsole from the Memgraph Platform image using the following command in Linux:
docker run -it --entrypoint=mgconsole memgraph/memgraph-platform
You can run only mgconsole application from the Memgraph Platform image using the following command in Windows and macOS:
docker run -it --entrypoint=mgconsole memgraph/memgraph-platform --host host.docker.internal
You can also consider using a standalone mgconsole
image as described in the CLI section.
You can run only the Memgraph Lab web application from the Memgraph Platform image using the following command:
docker run -p 3000:3000 memgraph/memgraph-platform -c /etc/supervisor/supervisord-lab-only.conf
Stop and start the instance
You can stop the instance with docker stop memgraph
.
You can restart the instance with docker start memgraph
Troubleshooting
Issues with loading Memgraph
docker load -i memgraph.tar.gz
Error during connect:
This error may indicate that the docker daemon is not running.
Run the Docker Desktop application and wait for it to load fully.
Error response from daemon:
open \\.\pipe\docker_engine_linux: The system cannot find the file specified.
Reload the Docker Desktop application and wait for it to load fully.
Unsupported OS Linux
You need to download the Windows Subsystem for Linux (opens in a new tab), and enable experimental features in Docker Desktop, under Settings -> Docker Engine, change experimental to true.
Issues when connecting to Memgraph Platform up to version 2.14
docker run memgraph/memgraph-platform
While this command will start a Memgraph instance, not publishing the port will
cause problems when trying to connect to the database via Memgraph Lab or
mgconsole. To avoid this, you should publish the
container's port to the host using the -p
flag and by specifying the port:
docker run -p 7687:7687 -p 7444:7444 -p 3000:3000 memgraph/memgraph-platform
Issues with connecting mgconsole
to the database
docker run -it --entrypoint=mgconsole memgraph/memgraph-platform --host HOST
Although unlikely, sometimes there are issues with connecting mgconsole to
the Docker Container’s IP address because it is running on a custom IP rather
than localhost
. This problem is most often accompanied with the following
error:
Connection failure: Couldn't connect to 127.0.0.1:7687!
To fix this issue, just replace HOST
from the first command with
host.docker.internal
. To find out more about networking in Docker, take a look
at Networking features in Docker Desktop for
Windows (opens in a new tab) guide or
Mac (opens in a new tab) guide .
Issues with the IP address
Although unlikely, some users might experience minor difficulties after the
Docker installation. Instead of running on localhost
, a Docker container for
Memgraph may be running on a custom IP address. Fortunately, that IP address can
be found as follows:
1. Determine the ID of the Memgraph Container by issuing the
command docker ps
. The user should get an output similar to the following:
CONTAINER ID IMAGE COMMAND CREATED
9397623cd87e memgraph "/usr/lib/memgraph/m…" 2 seconds ago
At this point, it is important to remember the container ID of the Memgraph
Image. In our case, that is 9397623cd87e
.
2. Use the this ID to retrieve the IP address of the Container:
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 9397623cd87e
The command above will yield the IP address that should be used when connecting
to Memgraph via Memgraph Lab or mgconsole. Just replace
HOST
from the following command with the appropriate IP address:
docker run -it --entrypoint=mgconsole memgraph/memgraph-platform --host HOST