我是ElasticSearch的新手,我在这里按照说明进行操作:https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
每当我运行“ docker-compose up”时,Kibana总是会说“无法恢复连接”,但是如果我运行curl http://localhost:9200,我会得到响应:
{
"name" : "ec88fa675367",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "UkLkAHO8S4yzAKFaf0KsYA",
"version" : {
"number" : "7.5.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "e9ccaed468e2fac2275a3761849cbee64b39519f",
"build_date" : "2019-11-26T01:06:52.518245Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
下面是我的docker-compose.yml,请帮助,谢谢!
version: '3'
networks:
elastic:
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
container_name: elasticsearch
networks:
- elastic
environment:
- discovery.type=single-node
ports:
- 9200:9200
kibana:
image: docker.elastic.co/kibana/kibana:7.5.0
container_name: kibana
networks:
- elastic
environment:
SERVER_NAME: kibana
ELASTICSEARCH_HOSTS: http://localhost:9200
links:
- elasticsearch
depends_on:
- elasticsearch
答案 0 :(得分:1)
它不起作用的原因是因为您将ELASICSEARCH_HOSTS
设置为Kibana主机(因为localhost代表kibana容器)。您需要做的是使用elasticsearch主机名ELASTICSEARCH_HOSTS: http://elasticsearch:9200
。
您还需要映射您的Kibana端口,否则您将无法从本地计算机访问它(类似于您对elasticsearch所做的操作)。
下面的示例应该起作用:
version: '3'
networks:
elastic:
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
container_name: elasticsearch
networks:
- elastic
environment:
- discovery.type=single-node
ports:
- 9200:9200
kibana:
image: docker.elastic.co/kibana/kibana:7.5.0
container_name: kibana
networks:
- elastic
environment:
SERVER_NAME: kibana
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
links:
- elasticsearch
depends_on:
- elasticsearch
ports:
- 5601:5601