警告:kibana无法通过http:// elasticsearch:9200连接到Elasticsearch

时间:2018-07-04 11:21:01

标签: docker elasticsearch docker-compose kibana

我将elasticsearch容器的IP地址放在elasticsearch_url / 并且我也尝试使用elasticsearch_url:http://localhost:9200,但我同样感到担忧: 我可以访问kibana的信息中心 当我卷曲时,“ http:/ IP_addres_of_the_container_elk:9200

{
  "name" : "qgn5tIw",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "UxAne7DGT6-lF9yp7hadYw",
  "version" : {
    "number" : "6.2.4",
    "build_hash" : "ccec39f",
    "build_date" : "2018-04-12T20:37:28.497551Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

这是我的docker-compose:

---
version: '2'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4
    container_name: elasticsearch
    hostname: elasticsearch
    environment:
      - http.port=9200
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
      - discovery.zen.minimum_master_nodes=1
      - discovery.type=single-node
      - cluster.routing.allocation.disk.threshold_enabled=false
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
  kibana:
    image: docker.elastic.co/kibana/kibana-oss:6.2.4
    environment:
      - elasticsearch_url= http://172.18.0.2:9200
      - verify_ssl= false
    volumes:
      - esdata2:/usr/share/kibana/config/data
    ports:
     - 5601:5601
    depends_on
     - elasticsearch
volumes:
  esdata1:
    driver: local
  esdata2:
    driver: local

请问有人可以帮忙吗?我错过了什么吗?

2 个答案:

答案 0 :(得分:0)

您必须添加elasticsearch容器作为链接

kibana:
    image: docker.elastic.co/kibana/kibana-oss:6.2.4
    environment:
      - elasticsearch_url= http://172.18.0.2:9200
      - verify_ssl= false
    volumes:
      - esdata2:/usr/share/kibana/config/data
    ports:
      - 5601:5601
    depends_on
      - elasticsearch
    links:
      - elasticsearch

答案 1 :(得分:0)

创建一个docker网络应该可以解决该问题。它可能会在启动时给您警告,但我认为这是正常的。等待几秒钟,它将连接。

最后,正如其他人所说,不要对IP进行硬编码。

尝试以下方法:

version: '2.2'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.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.2.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.2.4
    container_name: kibana
    ports:
      - 5601:5601
    networks:
      - esnet
    depends_on:
        - elasticsearch     

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

networks:
  esnet: