Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elasticsearch not reachable when using docker #484

Open
paulrusu8 opened this issue May 9, 2019 · 2 comments
Open

Elasticsearch not reachable when using docker #484

paulrusu8 opened this issue May 9, 2019 · 2 comments

Comments

@paulrusu8
Copy link

I have a docker-compose.yml file which declares webapp, postgres database, a two node elasticsearch, and a kibana container.

version: '3'
services:
  webapp:
    build:
      context: ../../../
      dockerfile: config/docker/dev/Dockerfile-dev
    container_name: MyWebApp-dev
    image: 'localhost:443/123'
    ports:
      - "4000:4000"
      - "3000:3000"
    depends_on:
      - db
      - elasticsearch
      - kibana
    links:
      - db
      - elasticsearch
      - kibana
  db:
    image: postgres:10
    container_name: db
    environment:
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=mine_dev
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1
    container_name: elasticsearch
    environment:
      - node.name=elasticsearch
      - discovery.seed_hosts=es02
      - cluster.initial_master_nodes=elasticsearch,es02
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - esnet
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1
    environment:
      - node.name=es02
      - discovery.seed_hosts=elasticsearch
      - cluster.initial_master_nodes=elasticsearch,es02
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata02:/usr/share/elasticsearch/data
    networks:
      - esnet

  kibana:
    image: docker.elastic.co/kibana/kibana:7.0.1
    ports:
      - "5601:5601"
    container_name: kibana

volumes:
  esdata01:
    driver: local
  esdata02:
    driver: local

networks:
  esnet:

They all build successfully, but kibana cannot get a live connection to elasticsearch

kibana           | {"type":"log","@timestamp":"2019-05-08T23:36:13Z","tags":["status","plugin:[email protected]","error"],"pid":1,"state":"red","message":"Status changed from red to red - No Living connections","prevState":"red","prevMsg":"Unable to connect to Elasticsearch."}

kibana           | {"type":"log","@timestamp":"2019-05-09T00:02:46Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}

and the index "products" cannot be created with elixir/ecto mix

MyWebApp-dev |   (elixir) lib/calendar/datetime.ex:537: DateTime.to_unix/2
MyWebApp-dev |   (elasticsearch) lib/elasticsearch/indexing/index.ex:287: Elasticsearch.Index.build_name/1
MyWebApp-dev |   (elasticsearch) lib/elasticsearch/indexing/index.ex:31: Elasticsearch.Index.hot_swap/2
MyWebApp-dev |   (elasticsearch) lib/mix/elasticsearch.build.ex:86: Mix.Tasks.Elasticsearch.Build.build/3
MyWebApp-dev | 
MyWebApp-dev | ** (Mix) Index products could not be created.
MyWebApp-dev | 
MyWebApp-dev |     %HTTPoison.Error{id: nil, reason: :econnrefused}

All the while, I can connect to the elasticsearch server:

A68MD-PRO:~# curl http://localhost:9200/_cat/health
1557359160 23:46:00 docker-cluster green 2 2 2 1 0 0 0 0 - 100.0%

Even from the container inside, curling yields:

A68MD-PRO:~# docker exec elasticsearch curl http://elasticsearch:9200/_cat/health
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    66  100    66    0     0   6969      0 --:--:-- --:--:-- --:--:--  7333
1557373042 03:37:22 docker-cluster green 2 2 2 1 0 0 0 0 - 100.0%

Does anyone know what this problem is about and how to solve it?

@pozhega
Copy link

pozhega commented Sep 9, 2020

I have the same issue. Have you managed to fix the problem?

@pozhega
Copy link

pozhega commented Sep 10, 2020

http://elasticsearch:9200/ instead of http://localhost:9200 in dev Dockerfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants