使用Docker连接到ElasticSearch的Kibana错误 - 无法恢复连接

时间:2018-05-25 15:08:33

标签: docker elasticsearch kibana

尝试使用Docker容器将Kibana连接到ES时出错:

kibana-products-624 | {"类型":"登录"" @时间戳":" 2018-05-25T14:56:36Z""标记":["警告"" elasticsearch""管理&#34]," PID":1,"消息& #34;:"无法恢复连接:http://elasticsearch:9200/"} kibana-products-624 | {"类型":"登录"" @时间戳":" 2018-05-25T14:56:36Z""标记":["警告"" elasticsearch""管理&#34]," PID":1,"消息& #34;:"没有生活联系"}

我在yml的环境设置和其他配置中尝试了许多变体,但仍然会出现此错误。

我已经使用CURL和浏览器验证了ElasticSearch正在运行并在端口9200上可用。

此配置有什么问题?

这是docker-compose.yml:

version: "3"

volumes:
elasticsearch-products-624-vol:

networks:
elasticsearch-net-624:

services:

elasticsearch-products-624-service:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
    container_name: elasticsearch-products-624
    restart: always
    networks:
    - elasticsearch-net-624
    environment:
        - cluster.name=docker-cluster
        - bootstrap.memory_lock=true
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        - xpack.security.enabled=true
    ulimits:
        memlock:
            soft: -1
            hard: -1
    ports:
    - "9200:9200"
    expose:
    - "9200"
    volumes:
    - elasticsearch-products-624-vol:/usr/share/elasticsearch/data

kibana-products-624-service:
    image: docker.elastic.co/kibana/kibana:6.2.4
    container_name: kibana-products-624
    hostname: kibana
    restart: always
    networks:
    - elasticsearch-net-624
    environment:
    - SERVER_NAME=kibana.localhost
    - ELASTICSEARCH_URL=http://elasticsearch:9200
    - ELASTICSEARCH_USERNAME=elastic
    - ELASTICSEARCH_HOST=elasticsearch
    - ELASTICSEARCH_PORT=9200
    - ELASTIC_PWD=changeme
    - KIBANA_PWD=changeme
    ports:
    - "5601:5601"
    expose:
    - "5601"
    links:
    - elasticsearch-products-624-service
    depends_on:
    - elasticsearch-products-624-service

1 个答案:

答案 0 :(得分:7)

ELASTICSEARCH_URL = http://elasticsearch:9200 应改为: ELASTICSEARCH_URL = http://elasticsearch-products-624:9200 引用上面实例化的容器。