0

I can't connect my project to ElasticSearch when I run it from Docker Compose. ElasticSearch cannot read the logs, but when I run it locally it works normally.

docker-compose: version: '3.9'

services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.11.1
    ports:
      - "9200:9200"
    networks:
      - network-elastic
    environment:
      discovery.type: single-node
      ES_JAVA_OPTS: "-Xms1g -Xmx1g"

  clinicaonline:
    build: .
    ports:
      - "5005:80"
    depends_on:
      - elasticsearch

networks: 
  network-elastic:
    driver: bridge

Connection string:

"Elasticsearch": {
    "Uri": "http://elasticsearch:9200"
  }
1
  • Don't you need to add network network-elastic to the clinicaonline service for them to be in the same network? Commented Apr 27, 2022 at 21:51

1 Answer 1

2

You need to add same the network(network-elastic) to the clinicaonline service. This should work:

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.11.1
    ports:
      - "9200:9200"
    networks:
      - network-elastic
    environment:
      discovery.type: single-node
      ES_JAVA_OPTS: "-Xms1g -Xmx1g"
  clinicaonline:
    build: .
    ports:
      - "5005:80"
    networks:
      - network-elastic
    depends_on:
      - elasticsearch
networks: 
  network-elastic:
    driver: bridge
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.