S
S
SSSSTTTTAAAASSSS2021-10-05 17:57:07
go
SSSSTTTTAAAASSSS, 2021-10-05 17:57:07

Can't connect gRPC to ElasticSearch via docker-compose?

Good afternoon!
At the moment I'm trying to connect ElasticSearch to my gRPC server to use it as storage, but during the general assembly, the connection to Elastic fails. Given that if you run separately Elastic through the default image in the docker, and then run gRPC separately, then they connect and work as expected. And together they don’t want to run through docker-compose up --build
If there is someone here who is a docker guru, please see where there could be an error? Where to dig?
I’ll tell you right away that what is commented out, I already tried it - it didn’t help. I changed the ports, registered the localhost, deleted it, set zeros, set the password and username, left it empty, did not set it. Set dependence_on, etc.
Here is my docker-compose which is the problem

grpc:
    container_name: "grpc"
    build:
      context: "./"
      dockerfile: "./docker/grpc.Dockerfile"
    ports:
      - "9000:9000"
    environment:
      TCP_PORT: ":9000"
      ELK_ADDR: "http://localhost:9200"

  elasticsearch:
    image: elasticsearch:7.14.1
    container_name: "elastic"
    environment:
      discovery.type: "single-node"
#      node.name: "elastic"
#      network.host: 0.0.0.0
#      network.publish_host: "_local_"
    ports:
      - "9200:9200"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
winshiftq, 2021-10-05
@winshiftq

On initial startup docker-compose up, creates a default network. After that, containers are created and linked to this network under the names grpc and elasticsearch. Within each container, you can look up the hostname of grpc or elasticsearch and get back the corresponding IP address of the container.
Therefore, in the ELK_ADDR variable, you need to specify the valuehttp://elasticsearch:9200

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question