Kibana无法在Docker上连接到Elasticsearch

时间:2019-06-11 08:57:11

标签: windows docker elasticsearch kibana

我正在关注https://www.elastic.co/guide/en/elasticsearch/reference/6.5/docker.htmlhttps://www.elastic.co/guide/en/kibana/6.5/docker.html 但这似乎不适用于kibana,ES效果很好。

我尝试单独启动kibana,但最终我将其添加到一个docker-compose文件中。

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.5.4
    container_name: elasticsearch
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - esnet
  elasticsearch2:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.5.4
    container_name: elasticsearch2
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata2:/usr/share/elasticsearch/data
    networks:
      - esnet

  kibana:
    image: docker.elastic.co/kibana/kibana:6.5.4
    volumes:
      - ./kibana.yml:/usr/share/kibana/config/kibana.yml  
    ports:
    - 5601:5601    

volumes:
  esdata1:
    driver: local
  esdata2:
    driver: local

networks:
  esnet:

Kibana.yml是:

server.host: "0.0.0.0"
server.name: "kibana"
elasticsearch.url: http://elasticsearch:9200

我收到以下错误:

  

kibana_1 | {“ type”:“ log”,“ @ timestamp”:“ 2019-06-11T08:55:30Z”,“ tags”:[“ warning”,“ elasticsearch”,“ admin”],“ pid”:1, “ message”:“无法恢复连接:http://elasticsearch:9200/”}

1 个答案:

答案 0 :(得分:4)

kibana容器与两个elasticsearch容器不在同一个网络上:它没有networks:块,因此在自动创建的{{1 }}网络上,但是两个default容器在显式声明的elasticsearch网络上。由于它们不在同一网络上,因此容器间DNS无法正常工作。

我建议只删除所有esnet块,并使用Docker Compose为您创建的默认网络。如果要使用显式命名的网络,请将相同的networks:行复制到networks: [esnet]服务块中。