5

I am trying to access mg_client inside a docker container but unfortunately, I am unable to connect it. I have followed instructions from the docs here

docker-compose.yaml

version: "3"
services:
  redis:
    image: redislabs/redisgraph
    container_name: redis
    restart: unless-stopped
    ports:
      - "6379:6379"

  memgraph:
    image: memgraph
    container_name: memgraph
    restart: unless-stopped
    ports:
      - "7687:7687"

CLI returns back an error -

enter image description here

Memgraph is successfully initialized as shown.

enter image description here

Strangely, if I execute it inside the container, I am able to connect.

enter image description here

What can be a possible mistake from my end?

PS: I am trying to create a Project with Memgraph, Neo4j, and RedisGraph running simultaneously and accessing each datastore using Python libs/adapter. This is the very initial step towards it.

Feedback would be appreciated.

Raj
  • 85
  • 8
  • 1
    Hi! It seems I understand the problem. When using `docker-compose`, things are not the same. I'm writing the full answer... – buda Feb 13 '21 at 11:00
  • What are the images you've attached to this question? Do you have the actual code you're using to connect to the server, and the actual error messages you're getting back? Please include these details as text in the question, not as images. – David Maze Feb 13 '21 at 11:38

1 Answers1

4

If standard docker run is used, I've managed to connect. Memgraph run command is

docker run --rm -p 7687:7687 --name test memgraph

Memgraph Docker run mg_client

If docker-compose is used, a network has to be defined:

version: "3"
services:
  memgraph:
    image: memgraph:1.3.0-community
    container_name: memgraph
    networks:
      - test_network
    container_name: memgraph
    restart: unless-stopped
    ports:
      - "7687:7687"
networks:
  test_network:
    driver: bridge

Memgraph docker-compose up

Please take care about the exact network name because docker-compose takes the {{folder_name}}_{{network_name}} as a network name. In my case, that's stack_issue_test_network. Since docker-compose 3.5, the network name can be defined, but I'm using 1.25 on Ubuntu 20.04 at this time.

The benefit of using this is that the IP resolution doesn't have to be done. The container name can be used instead.

Connecting to a Memgraph instance run by docker compose

A couple of final notes:

  • If you upgrade to Memgraph 1.3, --log-level=TRACE --also-log-to-stderr could be used to see more logs.
  • mg_client is a deprecated tool, since you are using Ubuntu, it should be relatively straightforward to install mgconsole and query Memgraph instances directly from the host machine. There is a plan to package mgconsole instead of mg_client in the future.
buda
  • 460
  • 4
  • 8
  • This answer serves my question. However, moving forward I would like to ask you few things 1) What are the volumes necessary to be mounted to the host machine in order to visualize any Graph data? 2) Is there any official docker image for memgraph available on the docker hub? 3) Is there a way to install mg_console without building it from the source? @user:4888809 – Raj Feb 13 '21 at 14:39
  • 1
    1) Volumes are not required to visualize data. Once an instance is running, data should be fetched via Bolt protocol and visualized somehow. 2) Memgraph doesn't provide the DockerHub image yet, but there is a plan to offer that soon. 3) The only way to install mgconsole is to build it from the source. In a similar way to how we plan to offer DockerHub image, there is a plan to put mgconsole in the repo. Before doing that, we'll probably ship mgconsole together with Memgraph so. There won't be a need to install it manually. – buda Feb 13 '21 at 17:21