在ubuntu上的docker上运行filebeat

问题描述 投票:0回答:1
  sudo docker run docker.elastic.co/beats/filebeat:7.0.0 setup -E setup.kibana.host=localhost:5601 -E output.elasticsearch.hosts=["localhost:9200"]

我想在带有elasticsearch的docker上运行filebeat,但是我收到了这个错误:

Exiting: Couldn't connect to any of the configured Elasticsearch hosts. Errors: [Error connection to Elasticsearch http://localhost:9200: Get http://localhost:9200: dial tcp 127.0.0.1:9200: connect: connection refused]

我找不到任何有用的解决方案......

docker elasticsearch kibana elastic-stack filebeat
1个回答
0
投票

从容器的角度来看,localhost本身并不是运行的主机,这就是它无法连接到elasticsearch的原因。

您需要在主机网络上运行filebeat容器或为其创建用户定义的网络,并将filebeat和elasticsearch连接到该网络。

例:

$ sudo docker network create mynetwork --driver bridge
$ sudo docker run -d -p 9200:9200 -p 9300:9300 --net=mynetwork --name elasticsearch -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.0.0
$ sudo docker run -d --name kibana --net=mynetwork -p 5601:5601 kibana:7.0.0
$ sudo docker run --net=mynetwork --name filebeat docker.elastic.co/beats/filebeat:7.0.0 setup -E setup.kibana.host=kibana:5601 -E output.elasticsearch.hosts=["elasticsearch:9200"]
© www.soinside.com 2019 - 2024. All rights reserved.