Sanjyot Agureddy
Sanjyot Agureddy

Reputation: 17

Logging to Elastic search is not working while pointing to docker url in Api docker image

Logging to Elastic search work fine when testing from local debugging to localhost app connection to elasticsearch url at https://localhost:9200, but it fails to connect with docker images of the dotnet.monitoring.api to the docker image of Elastic search at http://elasticsearch:9200 Below is the docker compose file.

version: '3.4'

services:
  productdb:
    container_name: productdb
    environment:
      SA_PASSWORD: "SwN12345678"
      ACCEPT_EULA: "Y"
    restart: always
    ports:
      - "1433:1433"

  elasticsearch:
    container_name: elasticsearch
    environment:
      - node.name=elasticsearch
      - cluster.name-es-docker-cluster
      - xpack.security.enabled=false
      - "discovery.type=single-node"
    networks:
      - es-net
    volumes:
      - data01:/urs/share/elasticsearch/data 
    ports:
      - 9200:9200

  kibana:
    container_name: kibana
    environment:
      - ELASTICSEARCH_URL=http://elasticsearch:9200
      - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
    networks:
      - es-net
    depends_on:
      - elasticsearch
    ports:
      - 5601:5601
  
  dotnet.monitoring.api:
    container_name: dotnet.monitoring.api
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - "ElasticConfiguration:Url=http://elasticsearch:9200/"
      - "ConnectionStrings:Product=server=productdb;Database=ProductDb;User Id=sa;Password=SampleP@&&W0rd;TrustServerCertificate=True;"
    depends_on:
      - productdb
      - kibana
    ports:
      - "8001:80"
volumes:
  data01:
    driver: local
networks:
  es-net:
    driver: bridge

Upvotes: 0

Views: 167

Answers (1)

Ahmet Arslan
Ahmet Arslan

Reputation: 6130

Your image of API is not in the same network. Make es-net as default.

networks:
  default:
    name: es-net
    external: true

Upvotes: 1

Related Questions