Reputation: 95
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 -
Memgraph is successfully initialized as shown.
Strangely, if I execute it inside the container, I am able to connect.
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.
Upvotes: 6
Views: 273
Reputation: 670
If standard docker run
is used, I've managed to connect. Memgraph run command is
docker run --rm -p 7687:7687 --name test memgraph
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
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.
A couple of final notes:
--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.Upvotes: 5